Slots related to endpoints and the HTTP context

This page is part of the magic.endpoint documentation.

In addition to the meta retrieval endpoint described above, the module contains the following slots.

  • [server.ip] - Returns the IP address of the server itself
  • [response.status.set] - Sets the status code (e.g. 404) on the response object
  • [request.cookies.list] - Lists all HTTP request cookies
  • [request.cookies.get] - Returns the value of a cookie sent by the request
  • [response.cookies.set] - Creates a cookie that will be returned to the client over the response
  • [request.headers.list] - Lists all HTTP request headers sent by the request
  • [request.headers.get] - Returns a single HTTP header associated with the request
  • [request.ip] - Returns the IP address of the HTTP request
  • [request.url] - Returns the relative URL associated with the request, without its magic/ prefix, and query parameters as children nodes as a key/value list
  • [request.host] - Returns the host name associated with the request
  • [request.scheme] - Returns the scheme associated with the request
  • [response.headers.set] - Adds an HTTP header to the response object
  • [mime.add] - Associates a file extension with a MIME type, only relevant for the HttpFileExecutorAsync resolver
  • [mime.list] - Lists registered MIME type mappings
  • [request.verb] - Returns the HTTP verb of the current invocation

Hyperlambda and cookies

Since cookies have more parameters than just a simple key/value declaration, the [response.cookies.set] slot takes the following arguments.

  • [value] - The string content of your cookie
  • [expires] - Absolute expiration date of your cookie, as a Hyperlambda date value
  • [http-only] - Boolean value declaring whether or not the cookie should only be accessible on the server
  • [secure] - Boolean value declaring whether or not cookie should only be transmitted from the client to the server over a secure (https) connection
  • [domain] - Domain value of your cookie
  • [path] - Path value of your cookie
  • [same-site] - Same-site value of your cookie

Only the [value] from above is mandatory. To delete a cookie on the client, set the expiration date to a value in the past.


← Hyperlambda code behind files all of magic.endpoint