gliew

Types

pub opaque type Response

Configuration for a server.

pub type Server {
  Server(
    port: Int,
    layout: fn(html.Node(Event)) -> html.Node(Event),
    handler: fn(Request(Body)) -> Response,
  )
}

Constructors

  • Server(
      port: Int,
      layout: fn(html.Node(Event)) -> html.Node(Event),
      handler: fn(Request(Body)) -> Response,
    )

Functions

pub fn append() -> Attr(Event)

Append the innerHTML of the live mount instead of replacing it.

pub fn live_mount(mount mount: fn(a) -> Subject(b), with context: a, render render: fn(
    Option(b),
  ) -> Node(Event)) -> Node(Event)

Creates a HTML node tree that will be mounted and receive live updates with data on Subject(a) returned by the mount function.

pub fn morph() -> Attr(Event)

Makes the live mount morph the diff of the innerHTML instead of replacing the whole thing.

pub fn new(port: Int, handler: fn(Request(Body)) -> Response) -> Server

Creates a configuration for a server with default layout.

pub fn on_click(node: Node(Event), do method: Method, to path: String) -> Node(
  Event,
)

Attaches an on-click handler to a node by specifying the HTTP method and path to make a request to when clicked.

pub fn response(status: Int) -> Response

Creates an empty response without a body.

pub fn script() -> Node(a)

Returns script tags to put into your own layout in order for live mounts to work.

pub fn serve(server: Server) -> Result(Nil, StartError)

Start server.

pub fn view(node: Node(Event), status: Int) -> Response

Creates a view response.

pub fn with_body(response: Response, body: String) -> Response

Sets body of a response.

pub fn with_header(response: Response, key key: String, value value: String) -> Response

Adds a header to a response.

Search Document