Net.HTTP.Method

lib/Net/HTTP/Method.gob

A request method, carrying the request's body where the method has one.

match req.method {
    GET -> ...
    POST(body) -> ...
}

The body is the method's payload, so a GET with a body cannot be written, and a server's match takes the body out of the pattern that picks the method. An extension method may or may not have one.

type Method b = GET | HEAD | DELETE | OPTIONS | TRACE | CONNECT | POST(b) | PUT(b) | PATCH(b) | Extension(MethodName, Option b)
type MethodName

The name of an extension method: a token, case kept, that is not one of the nine above. Refusing those keeps one spelling for each method, so Extension cannot write a GET that carries a body.

fun extension : fun(String) -> Option MethodName

Returns the extension method s names. Method names are case-sensitive, so get is an extension method and GET is not.

fun name : fun(Method b) -> String

Returns the method's name as it is sent: GET, POST, ...

fun isSafe : fun(Method b) -> Bool

Whether the method is safe (RFC 9110 §9.2.1): it asks only to read, so sending it changes nothing on the server. An extension method is not known to be.

fun isIdempotent : fun(Method b) -> Bool

Whether sending the request twice has the effect of sending it once (RFC 9110 §9.2.2), which is what lets a client send it again after a connection fails part-way.

fun body : fun(Method b) -> Option b
instance Show MethodName
instance Show (Method b)

Shows the name alone, never the body.

instance Functor Method

map(m, f) replaces the body, if the method has one, by f of it, and leaves the method as it is: a codec turns POST(bytes) into POST(decoded) without a match that names every method.