route

Attribute Macro route 

Source
#[route]
Expand description

Registers a function as a route handler.

This attribute macro registers the decorated function as a route handler for a given path. This macro requires the #[hyperlane(server: Server)] macro to be used to define the server instance.

§Usage

use hyperlane::*;
use hyperlane_macros::*;

#[route("/response")]
struct Response;

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

    #[response_body("response")]
    async fn handle(self, ctx: &Context) {}
}

§Parameters

  • path: String literal defining the route path

§Dependencies

This macro depends on the #[hyperlane(server: Server)] macro to define the server instance.