Loading ...
Sorry, an error occurred while loading the content.

Re: [rest-discuss] Different resource 'views'

Expand Messages
  • Roy T. Fielding
    ... I don t know of any sane system that uses the query portion to distinguish format-specific resources. Everybody uses name extensions for that purpose.
    Message 1 of 23 , Aug 6, 2008
    View Source
    • 0 Attachment
      On Aug 6, 2008, at 2:18 AM, Eric J. Bowman wrote:
      > I agree with the others, that you use content negotiation but allow
      > URI
      > parameters to override it, directly returning the desired variant.
      > This
      > works really well to test the output of conneg systems, without having
      > to muck about with browser settings or use curl. I say parameter, not
      > query, because your URIs don't represent queries -- the output format
      > has always seemed a parameter to me:
      >
      > /team/cubs;view=csv
      > /team/cubs;view=json
      >

      I don't know of any sane system that uses the query portion to
      distinguish format-specific resources. Everybody uses name
      extensions for that purpose. There is absolutely no good reason
      to do the above instead of

      /team/cubs.csv
      /team/cubs.json

      and plenty of reasons to avoid using query syntax.

      Have a look at Apache Sling for an example.

      ....Roy
    • Eric J. Bowman
      OK, you re right, but only as long as 1:1 mapping between content- type and representation, or a 1:1 mapping between an extension and a format, exist. The
      Message 2 of 23 , Aug 7, 2008
      View Source
      • 0 Attachment
        OK, you're right, but only as long as 1:1 mapping between content-
        type and representation, or a 1:1 mapping between an extension and a
        format, exist. The .csv and .json extensions have no ambiguity; the
        same can't be said for .html which might be text/html or
        application/xhtml+xml, or .xml which may be text/xml or application/
        xml, and so on.

        A sane system using the query portion, is one which distinguishes
        between representations rather than output formats, i.e. assume the
        following both render as JSON:

        /team/cubs;view=foo
        /team/cubs;view=bar

        The alternative being cubs.json and perhaps cubs.txt for the second
        JSON representation, which introduces ambiguous extensions, which seems
        like a good reason not to use file extensions, to me.

        An application may also serve XHTML 1.0, as application/xhtml+xml to
        compatible clients, and as text/html to other clients. Since there's
        only one file, its extension is moot, making URI parameters viable to
        specify the particular output serialization rather than having two
        copies of the same file, one as .htm and the other as .html...

        -Eric

        "Roy T. Fielding" wrote:

        > On Aug 6, 2008, at 2:18 AM, Eric J. Bowman wrote:
        > > I agree with the others, that you use content negotiation but
        > > allow URI
        > > parameters to override it, directly returning the desired variant.
        > > This
        > > works really well to test the output of conneg systems, without
        > > having to muck about with browser settings or use curl. I say
        > > parameter, not query, because your URIs don't represent queries --
        > > the output format has always seemed a parameter to me:
        > >
        > > /team/cubs;view=csv
        > > /team/cubs;view=json
        > >
        >
        > I don't know of any sane system that uses the query portion to
        > distinguish format-specific resources. Everybody uses name
        > extensions for that purpose. There is absolutely no good reason
        > to do the above instead of
        >
        > /team/cubs.csv
        > /team/cubs.json
        >
        > and plenty of reasons to avoid using query syntax.
        >
        > Have a look at Apache Sling for an example.
        >
        > ....Roy
        >
      • Bill de hOra
        ... What would they be? Bill
        Message 3 of 23 , Aug 7, 2008
        View Source
        • 0 Attachment
          Roy T. Fielding wrote:

          > I don't know of any sane system that uses the query portion to
          > distinguish format-specific resources. Everybody uses name
          > extensions for that purpose. There is absolutely no good reason
          > to do the above instead of
          >
          > /team/cubs.csv
          > /team/cubs.json
          >
          > and plenty of reasons to avoid using query syntax.

          What would they be?

          Bill
        • Subbu Allamaraju
          ... This could very well be written as /team/cubs.foo /team/cubs.bar I don t mean to say that one is better than the other though. These are syntactic
          Message 4 of 23 , Aug 7, 2008
          View Source
          • 0 Attachment
            On Aug 7, 2008, at 2:35 AM, Eric J. Bowman wrote:

            > A sane system using the query portion, is one which distinguishes
            > between representations rather than output formats, i.e. assume the
            > following both render as JSON:
            >
            > /team/cubs;view=foo
            > /team/cubs;view=bar
            >
            > The alternative being cubs.json and perhaps cubs.txt for the second
            > JSON representation, which introduces ambiguous extensions, which
            > seems
            > like a good reason not to use file extensions, to me.

            This could very well be written as

            /team/cubs.foo
            /team/cubs.bar

            I don't mean to say that one is better than the other though. These
            are syntactic variations that have the same tradeoffs.

            Subbu
          • Roy T. Fielding
            ... 1) It interferes with other uses of the query syntax (for queries); 2) It is often controlled by a different subsystem during operations, in a
            Message 5 of 23 , Aug 7, 2008
            View Source
            • 0 Attachment
              On Aug 7, 2008, at 6:17 AM, Bill de hOra wrote:
              > Roy T. Fielding wrote:
              >
              > > I don't know of any sane system that uses the query portion to
              > > distinguish format-specific resources. Everybody uses name
              > > extensions for that purpose. There is absolutely no good reason
              > > to do the above instead of
              > >
              > > /team/cubs.csv
              > > /team/cubs.json
              > >
              > > and plenty of reasons to avoid using query syntax.
              >
              > What would they be?
              >

              1) It interferes with other uses of the query syntax (for queries);
              2) It is often controlled by a different subsystem during operations,
              in a method-specific and implementation-specific manner, which
              makes it
              harder to preserve names when the implementation evolves;
              3) It looks like a query, so some caches don't bother to cache the
              response because the hit rate is lower than non-query responses;
              4) It looks like a potentially "unsafe" resource, so some (spineless)
              spiders won't traverse it and your site will disappear from search
              engines.

              ....Roy
            • Eric J. Bowman
              ... As to 3 and 4, the design pattern here is one of overriding content negotiation, which in my case at least is not expected to account for a significant
              Message 6 of 23 , Aug 8, 2008
              View Source
              • 0 Attachment
                >
                > 3) It looks like a query, so some caches don't bother to cache the
                > response because the hit rate is lower than non-query responses;
                > 4) It looks like a potentially "unsafe" resource, so some (spineless)
                > spiders won't traverse it and your site will disappear from search
                > engines.
                >
                > ....Roy
                >

                As to 3 and 4, the design pattern here is one of overriding content
                negotiation, which in my case at least is not expected to account for a
                significant percentage of requests. So, having /team/cubs cached and
                spidered properly seems sufficient, the individual variants' URIs don't
                really need caching or spidering.

                -Eric
              • Bill de hOra
                ... Looks like friendfeed don t have a sane system. Bill
                Message 7 of 23 , Aug 17, 2008
                View Source
                • 0 Attachment
                  Roy T. Fielding wrote:
                  >
                  >
                  > On Aug 7, 2008, at 6:17 AM, Bill de hOra wrote:
                  > > Roy T. Fielding wrote:
                  > >
                  > > > I don't know of any sane system that uses the query portion to
                  > > > distinguish format-specific resources. Everybody uses name
                  > > > extensions for that purpose. There is absolutely no good reason
                  > > > to do the above instead of
                  > > >
                  > > > /team/cubs.csv
                  > > > /team/cubs.json
                  > > >
                  > > > and plenty of reasons to avoid using query syntax.
                  > >
                  > > What would they be?
                  > >
                  >
                  > 1) It interferes with other uses of the query syntax (for queries);
                  > 2) It is often controlled by a different subsystem during operations,
                  > in a method-specific and implementation-specific manner, which
                  > makes it
                  > harder to preserve names when the implementation evolves;
                  > 3) It looks like a query, so some caches don't bother to cache the
                  > response because the hit rate is lower than non-query responses;
                  > 4) It looks like a potentially "unsafe" resource, so some (spineless)
                  > spiders won't traverse it and your site will disappear from search
                  > engines.

                  Looks like friendfeed don't have a sane system.

                  Bill
                • Bill de hOra
                  ... Or Yahoo pipes. I suspect this has to with UAs in general not doing conneg very well. Bill
                  Message 8 of 23 , Aug 17, 2008
                  View Source
                  • 0 Attachment
                    Bill de hOra wrote:
                    >
                    >
                    > Roy T. Fielding wrote:
                    > >
                    > >
                    > > On Aug 7, 2008, at 6:17 AM, Bill de hOra wrote:
                    > > > Roy T. Fielding wrote:
                    > > >
                    > > > > I don't know of any sane system that uses the query portion to
                    > > > > distinguish format-specific resources. Everybody uses name
                    > > > > extensions for that purpose. There is absolutely no good reason
                    > > > > to do the above instead of
                    > > > >
                    > > > > /team/cubs.csv
                    > > > > /team/cubs.json
                    > > > >
                    > > > > and plenty of reasons to avoid using query syntax.
                    > > >
                    > > > What would they be?
                    > > >
                    > >
                    > > 1) It interferes with other uses of the query syntax (for queries);
                    > > 2) It is often controlled by a different subsystem during operations,
                    > > in a method-specific and implementation-specific manner, which
                    > > makes it
                    > > harder to preserve names when the implementation evolves;
                    > > 3) It looks like a query, so some caches don't bother to cache the
                    > > response because the hit rate is lower than non-query responses;
                    > > 4) It looks like a potentially "unsafe" resource, so some (spineless)
                    > > spiders won't traverse it and your site will disappear from search
                    > > engines.
                    >
                    > Looks like friendfeed don't have a sane system.

                    Or Yahoo pipes. I suspect this has to with UAs in general not doing
                    conneg very well.

                    Bill
                  Your message has been successfully submitted and would be delivered to recipients shortly.