midas/http

Types

Method

pub type Method {
  Get
  Post
  Head
  Put
  Delete
  Trace
  Connect
  Options
  Patch
}

Constructors

  • Get
  • Post
  • Head
  • Put
  • Delete
  • Trace
  • Connect
  • Options
  • Patch

Request

pub type Request {
  Request(
    method: Method,
    path: String,
    query: Option(String),
    authority: String,
    headers: List(tuple(String, String)),
    body: String,
  )
}

Constructors

  • Request( method: Method, path: String, query: Option(String), authority: String, headers: List(tuple(String, String)), body: String, )

Response

pub type Response {
  Response(
    status: Int,
    headers: List(tuple(String, String)),
    body: String,
  )
}

Constructors

  • Response( status: Int, headers: List(tuple(String, String)), body: String, )

Functions

get_header

pub fn get_header(
  headers: List(tuple(a, b)),
  key: a,
) -> Result(a, Nil)

parse_query

pub fn parse_query(
  string: String,
) -> Result(List(tuple(String, String)), Nil)

split_segments

pub fn split_segments(path: String) -> List(String)