Skip to content

Commit

Permalink
Link OCaml Webapp Tutorial from README (#131)
Browse files Browse the repository at this point in the history
Link "Lightweight OCaml Webapp Tutorial" from README

Followup to #127
  • Loading branch information
shonfeder authored and anuragsoni committed Jan 3, 2020
1 parent 6ed2d45 commit ad61e35
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 8 additions & 2 deletions README.cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ $ opam pin add opium --dev-repo

## Documentation

For the API documentation:
For the **API documentation**:

- Read [the hosted documentation for the latest version][hosted-docs].
- Build and view the docs for version installed locally using [`odig`][odig]:
`odig doc opium`.

For examples of idiomatic usage, see the [./examples directory](./examples)
The following **tutorials** walk through various usecases of Opium:

- [A Lightweight OCaml Webapp Tutorial](https://shonfeder.gitlab.io/ocaml_webapp/)
covers a simple webapp generating dynamic HTML on the backend and
interfacing with PostgreSQL.

For **examples** of idiomatic usage, see the [./examples directory](./examples)
and the simple examples below.

[hosted-docs]: https://rgrinberg.github.io/opium/
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ $ opam pin add opium --dev-repo

## Documentation

For the API documentation:
For the **API documentation**:

- Read [the hosted documentation for the latest version][hosted-docs].
- Build and view the docs for version installed locally using [`odig`][odig]:
`odig doc opium`.

For examples of idiomatic usage, see the [./examples directory](./examples)
The following **tutorials** walk through various usecases of Opium:

- [A Lightweight OCaml Webapp Tutorial](https://shonfeder.gitlab.io/ocaml_webapp/)
covers a simple webapp generating dynamic HTML on the backend and
interfacing with PostgreSQL.

For **examples** of idiomatic usage, see the [./examples directory](./examples)
and the simple examples below.

[hosted-docs]: https://rgrinberg.github.io/opium/
Expand Down Expand Up @@ -76,14 +82,18 @@ let print_param =
put "/hello/:name" (fun req ->
`String ("Hello " ^ param req "name") |> respond')
let default =
not_found (fun req ->
`Json Ezjsonm.(dict [("message", string "Route not found")]) |> respond')
let print_person =
get "/person/:name/:age" (fun req ->
let person =
{name= param req "name"; age= "age" |> param req |> int_of_string}
in
`Json (person |> json_of_person) |> respond')
let _ = App.empty |> print_param |> print_person |> App.run_command
let _ = App.empty |> print_param |> print_person |> default |> App.run_command
```

compile and run with:
Expand Down

0 comments on commit ad61e35

Please sign in to comment.