Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bikallem/spring
Spring - A Delightful OCaml web programming library (unreleased)
https://github.com/bikallem/spring
Last synced: 3 months ago
JSON representation
Spring - A Delightful OCaml web programming library (unreleased)
- Host: GitHub
- URL: https://github.com/bikallem/spring
- Owner: bikallem
- License: mpl-2.0
- Created: 2023-02-21T13:21:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-26T15:46:41.000Z (10 months ago)
- Last Synced: 2024-05-31T10:40:00.185Z (6 months ago)
- Language: OCaml
- Homepage:
- Size: 928 KB
- Stars: 32
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring
A Delightful OCaml web programming library.
### Hightlights:
- [x] `ohtml` - a fast, compiled view engine allowing you to mix HTML with OCaml code
- [x] Type safe, radix-tree based url routing engine. Use ppx to specify route path, e.g. `[%r "/store/products/:int"]`
- [x] Form handling/data upload (multipart/formdata protocol - RFC 9110 - for standards compliance and interoperability)
- [x] CSRF form protection (Anti CSRF mechanism)
- [x] Secure HTTP session based on encrypted cookie
- [ ] Secure HTTP session based on SQLite/Postgres/Mysql
- [x] HTTP Cookies (RFC 6265)
- [x] Type-safe HTTP header manipulation
- [x] Fullly compliant (RFC 7230) HTTP chunked transfer protocol (both client and server)
- [x] HTTP file server - host/serve static web assets such as `.css, .js, .jpg, .png` etc
- [x] HTTP/1.1 (RFC 9112) multicore/parallel server/client
- [x] HTTPS/1.1 server/client (TLS/1.3)
- [x] Closely aligned with `eio` io library### Hello world in Spring [^1]
[^1]: See https://github.com/bikallem/spring/tree/main/examples/hello for full sample```hello.ml```
```ocaml
open Springlet say_hello _req = V.view ~title:"Hello Page" V.hello_v
let display_products _req =
V.products_v [ "apple"; "oranges"; "bananas" ]
|> V.view ~title:"Products Page"let () =
Eio_main.run @@ fun env ->
Server.app_server ~on_error:raise env#clock env#net
|> Server.get [%r "/"] say_hello
|> Server.get [%r "/products"] display_products
|> Server.run_local ~port:8080
``````hello_v.ohtml```
```html
Hello world!
``````layout_v.ohtml```
```html
fun ~title ~body ->
@title
{{ body }}
```
```products_v.ohtml```
```html
open Springfun products ->
Hello
world!
Products for sale
{ List.iter (fun product ->
@{if product = "apple" then "red apple" else product}
@producthello
@product
) products
}
```