/ocaml-web-framework

An HTTP server and framework written from scratch in OCaml

Primary LanguageOCaml

ocaml-web-framework

This is an HTTP server and framework written from scratch in OCaml. It uses UNIX sockets and builds up some abstractions to resemble the Sinatra framework.

This is just for fun - use rgrinberg/opium instead!

Thanks to Gary Bernhardt for his HTTP Server from Scratch screencast which inspired this project.

Build etc

$ make
$ make test

Example

open Framework
open Template

let () =
  create_server ()
  |> get "/" (fun req -> h1 ["This is the index page."] |> respond)
  |> get "/:name" (fun req ->
      Printf.sprintf "Hello, %s!" (param req "name") |> respond)
  |> listen 1337