[−][src]Macro http_guest::guest_app
Macro to set up the scaffolding
This macro takes care of setting up the scaffolding for the guest
code, including allocation, error handling, and conversion to and
from the http
crate's types. The template for user code should
look something like this:
#[macro_use]
extern crate http_guest;
use http_guest::{Request, Response};
pub fn user_entrypoint(req: &Request<Vec<u8>>) -> Response<Vec<u8>> {
if req.method().as_str() == "POST" {
Response::builder().status(200).body("Hello!".as_bytes().to_owned())
} else {
Response::builder().status(405).body(vec![])
}
}
guest_app!(user_entrypoint);