1. 57
  1.  

  2. 17

    The Reddit trick, with appending .json to the end, isn’t unique to that site. It’s a common trait in Rails apps (GitHub is the gigantic exception, but GitHub is both old and atypical for a Rails app).

    Here it is on lobsters: https://lobste.rs/s/31hkbx/four_cool_urls.json

    Here it is on users.rust-lang.org: https://users.rust-lang.org/t/passing-a-mutable-reference-based-on-self/24108.json (it applies to any other discourse.org-based forum)

    It’s basically implemented with respond_to “content negotiation”, which is smart enough to handle file suffixes as an override for the Accept header: https://stackoverflow.com/a/9492463/3754495

    1. 5

      The Reddit trick, with appending .json to the end, isn’t unique to that site. It’s a common trait in Rails apps

      To be clear to all, Reddit isn’t a Rails app, so you have to give them some credit. But that’s cool, I didn’t know that :-)

      1. 4

        As johnaj said, Reddit is (AFAIK) Python, but GitHub has some limited support for it: you can append .diff or .patch to a pull request or commit, for example.

        1. 3

          Whaaaat! I didn’t even know Lobsters could do that. Thanks for the tip cuz I definitely needed that.

          1. 2

            Similarly OData has the $format=media/type query parameter that I’ve seen other non-OData endpoints adopt.

          2. 4

            The six general principles listed at the end seem too wordy and redundant to be useful for remembering the lessons of the four URLs. So I would summarize them with these two principles:

            • make URLs self-contained (let them be useful even if the server is down)
            • make URLs editable (make the format obvious enough for manual editing to work)
            1. 6

              I created a URL scheme for the King James Bible that I felt was simple and elegant (and that was twenty years ago, sigh). I then did a similar approach to my blog URLs but based around dates, not books, chapters and verses.

              1. 1

                Those URL schemes are neat, but I think your comment is misplaced. You should delete and repost your comment as a reply to the top level, not to my comment.

                1. 1

                  My intent was to reply to the two principles of the article. My comment would also be relevant to /u/whjms currently just below mine, about making URLs editable.

                  I think I’ll just leave it here for now.

              2. 2

                make URLs editable

                I’ve thought about how the web would be different if manually editing URLs was the norm. For example, if web browsers generated a UI based on the query parameters that would let people easily change individual variables. Maybe sites could also add metadata to URL parameters.