https://github.com/zshipko/yurt
OCaml HTTP Microframework
https://github.com/zshipko/yurt
cohttp ocaml yurt
Last synced: about 1 year ago
JSON representation
OCaml HTTP Microframework
- Host: GitHub
- URL: https://github.com/zshipko/yurt
- Owner: zshipko
- License: isc
- Created: 2016-09-16T01:37:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-09T20:54:25.000Z (about 6 years ago)
- Last Synced: 2025-03-24T12:21:26.667Z (about 1 year ago)
- Topics: cohttp, ocaml, yurt
- Language: OCaml
- Homepage:
- Size: 247 KB
- Stars: 25
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.md
Awesome Lists containing this project
README
Yurt
====
`yurt` is an HTTP microframework for OCaml based on [Cohttp](https://github.com/mirage/ocaml-cohttp).
## Features
* Simple API
* Multipart forms
* Regex based URL routing
* Functional templates
## Installation
opam install yurt
## Usage
```ocaml
open Yurt
let _ =
let open Server in
(* Create a server *)
server "127.0.0.1" 1234
(* Add a handler *)
>| get "/" (fun req params body ->
(* Get the url parameter called `name` *)
let name = Route.string params "name" in
let body = Yurt_html.h1 (Printf.sprintf "Hello %s!\n" name) in
html body)
(* Run it *)
|> run
```
See `example/example.ml` for more examples.