mirror of
https://github.com/aantron/dream.git
synced 2025-08-25 00:02:41 -04:00
Tutorial
Dream's first several examples make up a tutorial. Each example is a
complete project with a helpful README
, and plenty of links to next steps and
documentation. You can begin at 1-hello
, or look in the
list below and jump to whatever interests you!
1-hello
— the simplest Dream server responds to every request with the same friendly message.2-middleware
— adds the first Dream middleware: the logger.3-router
— different handlers for different paths.4-counter
— the first custom middleware!5-promise
— introduces Lwt, the promise library used by Dream.6-echo
— reads request bodies.7-template
— renders responses from inline HTML templates and guards against XSS.8-debug
— includes detailed information about errors in responses.9-error
— customize all error responses in one place.a-log
— writing messages to Dream's log.b-session
— associates state with client sessions.c-cookie
— sets custom cookies.d-form
— reading forms and CSRF prevention.e-json
— sending and receiving JSON securely.f-static
g-upload
h-sql
— finally CRUD!i-graphql
j-stream
k-websocket
k-https
That's it for the tutorial!
Reason
There are several examples showing Dream with Reason syntax.
r-hello
r-template
r-template-stream
r-fullstack
Examples
The rest of the examples cover additional topics in a more-standalone fashion. The goal of the examples is to (eventually) cover the great majority of real-world HTTP usage, so that they make up a good survey. Please open an issue if something is missing!
w-long-polling
— asynchronous communication without WebSockets.w-query
— reading URL query parameters.w-server-sent-events
— the server side of JavaScriptEventSource
.w-site-prefix
— a Web app running not at/
.w-template-stream
— writing templates asynchronously, one chunk at a time.
Roadmap
These examples will be trickled in during the alpha releases.
Ideas:
w-auto-reload
w-fullstack
w-index-html
w-one-binary
w-ppx-deriving
w-react-spa
w-subcommand
w-template-directory
w-tyxml
— for TyXML templates.
Basics:
w-content-negotiation
w-query
— done.w-scope
— forDream.scope
.w-subsite
— for*
routes.w-testing
— for Testing.
Security:
w-auth
w-cookie-session
— forDream.cookie_sessions
.w-cors
w-sql-session
— forDream.sql_sessions
.w-file-session
w-form-expired
— for other cases ofDream.form
.w-json-csrf
— forDream.csrf_token
andX-CSRF-Token:
.w-jwt
w-key-rotation
— for a to-be-added~secrets
argument toDream.run
, which can specify multiple decryption keys.w-upload-csrf
— forDream.csrf_token
withDream.upload
.
Techniques:
w-etag
w-graphql-sql
w-graphql-subscriptions
w-https-redirect
w-long-polling
— done.w-postgres-docker
w-server-sent-events
— done.w-sql-stream
w-template-stream
— done.w-websocket-stream