lambda_lw_http_router_core

Trait RoutableHttpEvent

Source
pub trait RoutableHttpEvent:
    Send
    + Sync
    + Clone
    + 'static {
    // Required methods
    fn raw_path(&self) -> Option<String>;
    fn http_method(&self) -> String;

    // Provided methods
    fn resource(&self) -> Option<String> { ... }
    fn path_parameters(&self) -> Option<&HashMap<String, String>> { ... }
}
Expand description

A trait for HTTP events that can be routed by the router.

This trait defines the minimum requirements for an HTTP event to be usable with the routing system. Any event type that implements this trait can be used with the router.

§Examples

use lambda_lw_http_router_core::RoutableHttpEvent;
 
#[derive(Clone)]  // Required by RoutableHttpEvent
struct CustomHttpEvent {
    path: String,
    method: String,
}
 
impl RoutableHttpEvent for CustomHttpEvent {
    fn raw_path(&self) -> Option<String> {
        Some(self.path.clone())
    }
     
    fn http_method(&self) -> String {
        self.method.clone()
    }
}

Required Methods§

Source

fn raw_path(&self) -> Option<String>

Returns the raw path of the HTTP request

Source

fn http_method(&self) -> String

Returns the HTTP method of the request

Provided Methods§

Source

fn resource(&self) -> Option<String>

Returns the API Gateway resource pattern if available

Source

fn path_parameters(&self) -> Option<&HashMap<String, String>>

Returns pre-parsed path parameters if available

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RoutableHttpEvent for AlbTargetGroupRequest

Source§

impl RoutableHttpEvent for ApiGatewayProxyRequest

Source§

impl RoutableHttpEvent for ApiGatewayV2httpRequest

Source§

impl RoutableHttpEvent for ApiGatewayWebsocketProxyRequest

Implementors§