← all modules

Sky.Http.Server

Sky.Http.Server
  Sky.Http.Server — HTTP server (Layer 3 Sky source).

Types
  type alias Request
  type alias Response
  type alias Handler
  type Route = Route_OPAQUE
  type Server = Server_OPAQUE
  type Cookie = Cookie_OPAQUE

Values
  any : String -> (Request -> Task Error Response) -> Route
      `any path handler` — register a route that matches any HTTP
  api : String -> (Request -> Task Error Response) -> Route
      `api spec handler` — register an API route that bypasses
  body : Request -> String
      The raw request body.
  cookie : String -> String -> Cookie
      `cookie name value` — build a default cookie (Path=/, HttpOnly,
  delete : String -> (Request -> Task Error Response) -> Route
      `delete path handler` — register a DELETE route.
  formValue : String -> Request -> String
      `formValue name req` — read a parsed form field.  Unlike `param` /
  get : String -> (Request -> Task Error Response) -> Route
      `get path handler` — register a GET route.
  getCookie : String -> Request -> Maybe String
      `getCookie name req` — read a cookie value.
  header : String -> Request -> Maybe String
      `header name req` — read a request header (case-insensitive).
  html : String -> Response
      `html body` — build a 200 OK `text/html` response.  CSRF
  json : String -> Response
      `json body` — build a 200 OK `application/json` response.
  listen : Int -> List Route -> Task Error ()
      `listen port routes` — bind the server.  The returned Task
  method : Request -> String
      The request method (`"GET"`, `"POST"`, …).  Equivalent to the
  param : String -> Request -> Maybe String
      `param name req` — read a URL path parameter
  path : Request -> String
      The request path (`"/users/42"`), without the query string.
  post : String -> (Request -> Task Error Response) -> Route
      `post path handler` — register a POST route.
  put : String -> (Request -> Task Error Response) -> Route
      `put path handler` — register a PUT route.
  queryParam : String -> Request -> Maybe String
      `queryParam name req` — read a `?key=value`-style query string
  redirect : String -> Response
      `redirect url` — build a 302 response that points the client
  static : String -> String -> Route
      `static urlPrefix diskPath` — serve files from `diskPath` at
  text : String -> Response
      `text body` — build a 200 OK `text/plain` response.
  withCookie : any
      `withCookie` — attach a cookie to a response.  Three call
  withHeader : String -> String -> Response -> Response
      `withHeader name value resp` — add (or override) a response
  withStatus : Int -> Response -> Response
      `withStatus code resp` — override the status code.