diff --git a/Cargo.toml b/Cargo.toml index 8d0989c5..18e51f5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ exclude = [ "apps/documentation", "examples/with-mdx", "examples/tuono-app", + "examples/tuono-api", "examples/tuono-tutorial", "benches/tuono" ] diff --git a/examples/tuono-api/.gitignore b/examples/tuono-api/.gitignore new file mode 100644 index 00000000..eb323a3c --- /dev/null +++ b/examples/tuono-api/.gitignore @@ -0,0 +1,2 @@ +.tuono +target diff --git a/examples/tuono-api/Cargo.toml b/examples/tuono-api/Cargo.toml new file mode 100644 index 00000000..de68d117 --- /dev/null +++ b/examples/tuono-api/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "tuono-api" +version = "0.0.1" +edition = "2021" + +[[bin]] +name = "tuono" +path = ".tuono/main.rs" + +[dependencies] +tuono_lib = { path = "../../crates/tuono_lib/", features = ["api"]} + diff --git a/examples/tuono-api/README.md b/examples/tuono-api/README.md new file mode 100644 index 00000000..649dae09 --- /dev/null +++ b/examples/tuono-api/README.md @@ -0,0 +1,7 @@ +# Tuono API started + +This is the starter tuono project. To download it run in your terminal: + +```shell +$ tuono new [NAME] --template tuono-api +``` diff --git a/examples/tuono-api/public/.gitkeep b/examples/tuono-api/public/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/examples/tuono-api/src/routes/index.rs b/examples/tuono-api/src/routes/index.rs new file mode 100644 index 00000000..5e56170b --- /dev/null +++ b/examples/tuono-api/src/routes/index.rs @@ -0,0 +1,12 @@ +use tuono_lib::axum::http::StatusCode; +use tuono_lib::Request; + +#[tuono_lib::api(GET)] +pub async fn root_route_api(_req: Request) -> &'static str { + "get request" +} + +#[tuono_lib::api(POST)] +pub async fn root_route_api_post(_req: Request) -> StatusCode { + StatusCode::OK +}