Skip to content

Hello World

Package: examples/hello_world. This is the same app as First application, expanded into a checklist you can run.

Terminal window
cd examples/hello_world
siderite run

The binary listens on 127.0.0.1:8000 unless ADDR is set.

Method Path Handler
GET / index — PlainText("Hello, siderite!")
GET /hello/{name} hello — path + query (shout)
POST /echo echo — JSON Message with min_length = 1
Terminal window
curl -s http://127.0.0.1:8000/
curl -s 'http://127.0.0.1:8000/hello/ann?shout=true'
curl -s -X POST http://127.0.0.1:8000/echo \
-H 'content-type: application/json' \
-d '{"message":"hi"}'
curl -s -X POST http://127.0.0.1:8000/echo \
-H 'content-type: application/json' \
-d '{"message":""}'

The empty message is 422. OpenAPI lives at /docs, /redoc, and /openapi.json.

  • #[get] / #[post] plus routes![]
  • Path<T> and Query<T> for URL data
  • #[derive(Deserialize, Validate, Schema)] on request bodies
  • App::new().title(..).version(..).routes(..).run(..)

Next: Todo on SQLite.