Skip to content

Commit c0f75aa

Browse files
authored
Merge pull request #92 from anuragsoni/update-opam-file
Remove `cow` from deps as it isn't used anywhere
2 parents 5b9193b + 4764613 commit c0f75aa

File tree

5 files changed

+28
-39
lines changed

5 files changed

+28
-39
lines changed

Diff for: README.cpp.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Opium
33

44
## Executive Summary
55

6-
Sinatra like web toolkit for OCaml based on [cohttp](https://github.com/avsm/ocaml-cohttp/) & [lwt](https://github.com/ocsigen/lwt)
6+
Sinatra like web toolkit for OCaml based on [cohttp](https://github.com/mirage/ocaml-cohttp/) & [lwt](https://github.com/ocsigen/lwt)
77

88
## Design Goals
99

@@ -15,15 +15,11 @@ _Rack_ inspired mechanism borrowed from Ruby. The middleware mechanism in
1515
Opium is called `Rock`.
1616

1717
* It should maximize use of creature comforts people are used to in
18-
other languages. Such as [sexplib](https://github.com/janestreet/sexplib), [fieldslib](https://github.com/janestreet/fieldslib), [cow](https://github.com/mirage/ocaml-cow), a decent
18+
other languages. Such as [sexplib](https://github.com/janestreet/sexplib), [fieldslib](https://github.com/janestreet/fieldslib), a decent
1919
standard library.
2020

2121
## Installation
2222

23-
__NOTE__: At this point there's a good chance this library will only
24-
work against cohttp master. Once cohttp 1.0 is released then this
25-
library will always be developed against OPAM version.
26-
2723
### Stable
2824

2925
The latest stable version is available on opam
@@ -43,9 +39,9 @@ $ opam pin add opium --dev-repo
4339

4440
## Examples
4541

46-
All examples are built once the necessary dependencies are installed (`cow`).
47-
`$ make` will compile all examples. The binaries are located in
48-
`_build/examples/`
42+
All examples are built once the necessary dependencies are installed.
43+
`$ dune build @examples` will compile all examples. The binaries are located in
44+
`_build/default/examples/`
4945

5046
### Hello World
5147

Diff for: README.md

+22-27
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,17 @@ _Rack_ inspired mechanism borrowed from Ruby. The middleware mechanism in
1515
Opium is called `Rock`.
1616

1717
* It should maximize use of creature comforts people are used to in
18-
other languages. Such as [sexplib](https://github.com/janestreet/sexplib), [fieldslib](https://github.com/janestreet/fieldslib), [cow](https://github.com/mirage/ocaml-cow), a decent
18+
other languages. Such as [sexplib](https://github.com/janestreet/sexplib), [fieldslib](https://github.com/janestreet/fieldslib), a decent
1919
standard library.
2020

2121
## Installation
2222

23-
__NOTE__: At this point there's a good chance this library will only
24-
work against cohttp master. Once cohttp 1.0 is released then this
25-
library will always be developed against OPAM version.
26-
2723
### Stable
2824

2925
The latest stable version is available on opam
3026

3127
```
32-
opam install opium
28+
$ opam install opium
3329
```
3430

3531
### Master
@@ -38,20 +34,20 @@ If you'd like to live on the bleeding edge (which is sometimes more stable than
3834
stable)
3935

4036
```
41-
opam pin add opium --dev-repo
37+
$ opam pin add opium --dev-repo
4238
```
4339

4440
## Examples
4541

46-
All examples are built once the necessary dependencies are installed (`cow`).
47-
`make` will compile all examples. The binaries are located in
48-
`_build/examples/`
42+
All examples are built once the necessary dependencies are installed.
43+
`$ dune build @examples` will compile all examples. The binaries are located in
44+
`_build/default/examples/`
4945

5046
### Hello World
5147

5248
Here's a simple hello world example to get your feet wet:
5349

54-
`cat hello_world.ml`
50+
`$ cat hello_world.ml`
5551

5652
``` ocaml
5753
open Opium.Std
@@ -87,14 +83,13 @@ let _ =
8783

8884
compile with:
8985
```
90-
ocamlbuild -pkg opium hello_world.native
86+
$ ocamlbuild -pkg opium.unix hello_world.native
9187
```
9288

9389
and then call
94-
```
95-
./hello_world.native &
96-
curl http://localhost:3000/person/john_doe/42
97-
```
90+
91+
./hello_world.native &
92+
curl http://localhost:3000/person/john_doe/42
9893

9994
You should see a JSON message.
10095

@@ -115,13 +110,13 @@ favourite browser.
115110

116111
``` ocaml
117112
open Opium.Std
118-
open Opium_misc
119113
120114
(* don't open cohttp and opium since they both define
121115
request/response modules*)
122116
123-
let is_substring ~substring s =
124-
Option.is_some (String.substr_index s ~pattern:substring)
117+
let is_substring ~substring =
118+
let re = Re.compile (Re.str substring) in
119+
Re.execp re
125120
126121
let reject_ua ~f =
127122
let filter handler req =
@@ -131,18 +126,18 @@ let reject_ua ~f =
131126
| _ -> handler req in
132127
Rock.Middleware.create ~filter ~name:"reject_ua"
133128
134-
let _ = App.empty
135-
|> get "/" (fun req -> `String ("Hello World") |> respond')
136-
|> middleware (reject_ua ~f:(is_substring ~substring:"MSIE"))
137-
|> App.cmd_name "Reject UA"
138-
|> App.run_command
139-
129+
let _ =
130+
App.empty
131+
|> get "/" (fun _ -> `String ("Hello World") |> respond')
132+
|> middleware (reject_ua ~f:(is_substring ~substring:"MSIE"))
133+
|> App.cmd_name "Reject UA"
134+
|> App.run_command
140135
```
141136

142137
Compile with:
143138

144139
```
145-
ocamlbuild -pkg opium middleware_ua.native
140+
$ ocamlbuild -pkg opium.unix middleware_ua.native
146141
```
147142

148143
Here we also use the ability of Opium to generate a cmdliner term to run your
@@ -151,5 +146,5 @@ you. For example:
151146

152147
```
153148
# run in debug mode on port 9000
154-
./middleware_ua.native -p 9000 -d
149+
$ ./middleware_ua.native -p 9000 -d
155150
```

Diff for: examples/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
)
1111

1212
(alias
13-
(name DEFAULT)
13+
(name examples)
1414
(deps auth_middleware.exe exit_hook_example.exe hello_world_basic.exe hello_world_html.exe hello_world.exe middleware_ua.exe read_json_body.exe sample.exe static_serve_override.exe uppercase_middleware.exe)
1515
)

Diff for: opium.opam

-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ depends: [
3636
"magic-mime"
3737
"stringext"
3838
"alcotest" {with-test}
39-
"cow" {with-test & >= "0.10.0"}
4039
]

Diff for: opium_kernel.opam

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ depends: [
3232
"ppx_sexp_conv" {>= "v0.9.0"}
3333
"re" {>= "1.3.0"}
3434
"alcotest" {with-test}
35-
"cow" {with-test & >= "0.10.0"}
3635
]

0 commit comments

Comments
 (0)