When a Runnable is used to handle an HTTP request, Atmo will bind that request to the Runnable. The req
namespace of the Runnable API can then be used to access all of the information about the request. Note if the Runnable is not being used to handle a request, then all methods in the req
namespace will return empty or an error.
For Rust, these methods are available under the req
module, for example req::method()
. For Swift, they are prefixed with Req
, for example Suborbital.ReqMethod()
The following namespace methods are available:
Returns the HTTP method for the request
pub fn method() -> String
public func ReqMethod() -> String
Returns the full URL of the request
pub fn url() -> String
public func ReqURL() -> String
Returns the unique ID assigned to the request by Atmo
pub fn id() -> String
public func ReqID() -> String
Returns the full request body as bytes
pub fn body_raw() -> Vec<u8>
public func ReqBodyRaw() -> String
Returns the value for the provided key, if the request body is formatted as JSON
pub fn body_field(key: &str) -> String
public func ReqBodyField(key: String) -> String
Returns the header value for the provided key
pub fn header(key: &str) -> String
public func ReqHeader(key: String) -> String
Returns the URL parameter for the provided key, for example /api/v1/user/:uuid
pub fn url_param(key: &str) -> String
public func ReqParam(key: String) -> String
Returns the value from request state for the provided key
pub fn state(key: &str) -> String
public func State(key: String) -> String