#[response_status_code]Expand description
Sets the HTTP status code for the response.
This attribute macro configures the HTTP status code that will be sent with the response. The status code can be provided as a numeric literal or a global constant.
ยงUsage
use hyperlane::*;
use hyperlane_macros::*;
const CUSTOM_STATUS_CODE: i32 = 200;
#[route("/response_status_code")]
struct ResponseStatusCode;
impl ServerHook for ResponseStatusCode {
async fn new(_ctx: &Context) -> Self {
Self
}
#[response_status_code(CUSTOM_STATUS_CODE)]
async fn handle(self, ctx: &Context) {}
}
impl ResponseStatusCode {
#[response_status_code(CUSTOM_STATUS_CODE)]
async fn response_status_code_with_ref_self(&self, ctx: &Context) {}
}
#[response_status_code(200)]
async fn standalone_response_status_code_handler(ctx: &Context) {}The macro accepts a numeric HTTP status code or a global constant
and should be applied to async functions that accept a &Context parameter.