response_status_code

Attribute Macro response_status_code 

Source
#[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")]
struct Response;

impl ServerHook for Response {
    async fn new(_ctx: &Context) -> Self {
        Self
    }

    #[response_status_code(CUSTOM_STATUS_CODE)]
    async fn handle(self, 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.