land_sdk/lib.rs
1//! # Rust SDK for Runtime.land.
2//!
3//! This SDK is used to develop Runtime.land functions.
4//! It provides a set of methods to handle http request and response via `land_sdk::http` module on Runtime.land.
5//!
6//! # Hello World
7//!
8//! ```no_run
9//! use land_sdk::http::{Body, Error, Request, Response};
10//! use land_sdk::http_main;
11//!
12//! #[http_main]
13//! pub fn handle_request(req: Request) -> Result<Response, Error> {
14//! // read uri and method from request
15//! let url = req.uri().clone();
16//! let method = req.method().to_string().to_uppercase();
17//!
18//! // build response
19//! Ok(http::Response::builder()
20//! .status(200)
21//! .header("X-Request-Url", url.to_string())
22//! .header("X-Request-Method", method)
23//! .body(Body::from("Hello Runtime.land!!"))
24//! .unwrap())
25//! }
26//! ```
27//!
28
29// Make sure all our public APIs have docs.
30#![warn(missing_docs)]
31
32mod body;
33mod fetch;
34mod http_service;
35
36pub mod http;
37pub mod router;
38
39/// Re-export macro from sdk-macro
40pub use land_sdk_macro::http_main;