On 7 Jan 2019, at 0:16, Matthew Butterick wrote:
Don't know if it would be an instructive example, but the Pollen
project server [1], though not intended for production use, is a
self-contained HTTP server that handles dynamic generation of HTML (it
even works with Scribble files), which sounds similar to what you're
trying to do.
Jesse Alama's book Server: Racket [2] is an excellent resource. Among
many other things, I learned that you can invent arbitrary HTTP
methods beyond GET and POST, thereby avoiding encoding conventions
like "?action=edit". Instead, you can just have an HTTP method called
EDIT.
In Stephen's case, I think the classical HTTP method PUT is a good
match. PUT is intended to mean, roughly (precise definition at [1]):
here, take this request body; *it* will be the content in response
bodies to GET requests for this URL from now on.
One of my favorite examples of custom (non-canonical) HTTP methods is
for "cancelling" something (an order, an edit, some item of some group).
CANCEL https://example.com/order/4567
I find this method-URL pair more palatable than something like
POST https://example.com/cancel/order/4567
where the action (cancelling) is part of the URL.
Alas, not all browsers support such HTTP methods (such requests may get
silently converted into POSTs, despite your wishes), so they tend to be
relevant only in scenarios where you're using programmable HTTP clients
(e.g., command line tools such as cURL or Httpie [2], or libraries such
as Greg Hendershott's http [3]).
Jesse
[1] https://tools.ietf.org/html/rfc2616#section-9.6
[2] https://httpie.org
[3] https://pkgs.racket-lang.org/package/http
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.