User authentication and session management for web applications
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

auth: rewrite README example into compilation-unit style

The Quick Start snippet had collapsed statements and an unclear
server setup. Rewrite it with explicit `let ... in` steps for
config, store, routes, and server startup.

+21 -14
+21 -14
README.md
··· 18 18 ## Quick Start 19 19 20 20 ```ocaml 21 - Eio_main.run @@ fun env -> 22 - Eio.Switch.run @@ fun sw -> 23 - let fs = Eio.Stdenv.fs env in 24 - let http = Requests.v ~sw env in 25 - let store = Auth.Store.v ~sw Eio.Path.(fs / "data" / "auth.db") in 26 - let cfg = 27 - Auth.config ~oauth_provider:Oauth.Github ~client_id:"Iv1.abc" 28 - ~client_secret:"secret" ~base_url:"https://app.com" 29 - ~cookie_secret:"32-char-min-secret-for-signing!" ~http () 30 - in 31 - let routes = Auth.routes cfg store in 32 - Respond.run ~net:(Eio.Stdenv.net env) ~port:8080 33 - ~root:Eio.Path.(fs / "static") 34 - routes 21 + let () = 22 + Eio_main.run @@ fun env -> 23 + Eio.Switch.run @@ fun sw -> 24 + let fs = Eio.Stdenv.fs env in 25 + let http = Requests.v ~sw env in 26 + let store = Auth.Store.v ~sw Eio.Path.(fs / "data" / "auth.db") in 27 + let cfg = 28 + Auth.config 29 + ~oauth_provider:Oauth.Github 30 + ~client_id:"Iv1.abc" 31 + ~client_secret:"secret" 32 + ~base_url:"https://app.com" 33 + ~cookie_secret:"32-char-min-secret-for-signing!" 34 + ~http () 35 + in 36 + let routes = Auth.routes cfg store in 37 + Respond.run 38 + ~net:(Eio.Stdenv.net env) 39 + ~port:8080 40 + ~root:Eio.Path.(fs / "static") 41 + routes 35 42 ``` 36 43 37 44 The library registers three routes: