gleam/http
Functions for working with HTTP data structures in Gleam.
This module makes it easy to create and modify Requests and Responses, data types. A general HTTP message type is defined that enables functions to work on both requests and responses.
This module does not implement a HTTP client or HTTP server, but it can be used as a base for them.
Types
A HTTP header is a key-value pair. Header keys should be all lowercase characters.
pub type Header =
#(String, String)
Functions
pub fn method_from_dynamic(value: Dynamic) -> Result(
Method,
List(DecodeError),
)
pub fn method_to_string(method: Method) -> String
pub fn parse_method(s: String) -> Result(Method, Nil)
pub fn scheme_from_string(scheme: String) -> Result(Scheme, Nil)
Parse a HTTP scheme from a string
Examples
> scheme_to_string("http")
Ok(Http)
> scheme_to_string("ftp")
Error(Nil)
pub fn scheme_to_string(scheme: Scheme) -> String
Convert a scheme into a string.
Examples
> scheme_to_string(Http)
"http"
> scheme_to_string(Https)
"https"