stego

Types

pub type Body =
  body.Body

Functions

pub fn serve(
  server: fn(Request(Body)) -> Promise(Response(a)),
) -> Nil

Deno.serve, but for Gleam!

Deno.serve allows you to create a server using the web standard Request and Response types. Stego translates between these types and Gleam’s own Request and Response types. Your response body can be a BitArray, String, or StringBuilder.

Examples
import gleam/http/response
import gleam/javascript/promise
import stego

pub fn main() {
  stego.serve(fn (_request) {
    response.new(200)
    |> response.set_header("content-type", "text/html; charset=utf-8")
    |> response.set_body("<h1>hoi!</h1>")
    |> promise.resolve()
  })
}
Search Document