Hello World
Package: examples/hello_world. This is the same app as
First application, expanded into a checklist you can
run.
cd examples/hello_worldsiderite runThe binary listens on 127.0.0.1:8000 unless ADDR is set.
Routes
Section titled “Routes”| Method | Path | Handler |
|---|---|---|
GET |
/ |
index — PlainText("Hello, siderite!") |
GET |
/hello/{name} |
hello — path + query (shout) |
POST |
/echo |
echo — JSON Message with min_length = 1 |
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.
What to copy
Section titled “What to copy”#[get]/#[post]plusroutes![]Path<T>andQuery<T>for URL data#[derive(Deserialize, Validate, Schema)]on request bodiesApp::new().title(..).version(..).routes(..).run(..)
Next: Todo on SQLite.