Nanyx
PlaygroundPackages

wire

How the runtime's HTTP imports write requests and responses

nanyx.http.core/wire is for hosts, not programs: it writes and reads requests and responses as the nanyx runtime’s own imports, nanyx:http and nanyx:serve, pass them. The console host and the HTTP host use it.

Reference

How the nanyx runtime’s own HTTP imports, nanyx:http and nanyx:serve, write requests and responses, for the hosts written on them. A program doesn’t need it.

A request is written as lines, each ended by \n: its method, its URL, its timeout in milliseconds, how many headers it has, and each header’s name and value on lines of their own; its body follows, as it is. A response is written the same way: its status, how many headers it has, each header’s name and value, then its body.

methodName

def methodName: Method -> string

method’s name, as HTTP writes it: GET for #get.

methodOf

def methodOf: string -> #some(Method) | #unknown

The method HTTP writes as name, or #unknown.

writeRequest

def writeRequest: Request -> string

request, written.

readRequest

def readRequest: string -> #some(Request) | #malformed

The request written in text.

writeResponse

def writeResponse: Response -> string

response, written.

readResponse

def readResponse: string -> #some(Response) | #malformed

The response written in text.