marteinn / Vaja-Bob

A micro web framework for Väja.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vaja-Bob

A micro web framework for Väja.

Example

import Bob

let app = \
  Bob.new() \
  |> Bob.addMiddlewares([Bob.debugMiddleware, Bob.rendererMiddleware]) \
  |> Bob.addRoute404(fn(conn, _) -> {"status": 404, "body": "Page not found"}) \
  |> Bob.addRoutes([
    [
      Bob.newPath("/artist/([a-z]*)/"),
      fn(_conn, args) -> Bob.newJSONResponse({"status": 200, "context": {
        "artist": args[0]
      }})
    ]
  ])

Http.createServer() \
|> Http.addHandler(
  app |> Bob.makeHandler()
) \
|> Http.listen(8080)

License

This project is released under the MIT License.

About

A micro web framework for Väja.