Trait RoutableHttpEvent

Source
pub trait RoutableHttpEvent:
    Send
    + Sync
    + Clone
    + 'static {
Show 13 methods // Required methods fn path(&self) -> Option<String>; fn http_method(&self) -> String; // Provided methods fn route(&self) -> Option<String> { ... } fn path_parameters(&self) -> Option<&HashMap<String, String>> { ... } fn url_query(&self) -> Option<String> { ... } fn client_address(&self) -> Option<String> { ... } fn http_headers(&self) -> Option<&HeaderMap> { ... } fn response_headers(&self) -> Option<&HeaderMap> { ... } fn user_agent(&self) -> Option<String> { ... } fn url_scheme(&self) -> String { ... } fn server_address(&self) -> Option<String> { ... } fn server_port(&self) -> Option<u16> { ... } fn set_otel_http_attributes( &self, span: &Span, route_pattern: &str, lambda_context: &Context, ) { ... }
}
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, as well as OpenTelemetry semantic conventions for HTTP spans. Any event type that implements this trait can be used with the router and will automatically get standardized span attributes.

§Examples

use lambda_lw_http_router_core::RoutableHttpEvent;
use http::HeaderMap;

#[derive(Clone)]  // Required by RoutableHttpEvent
struct CustomHttpEvent {
    path: String,
    method: String,
    headers: HeaderMap,
}

impl RoutableHttpEvent for CustomHttpEvent {
    fn path(&self) -> Option<String> {
        Some(self.path.clone())
    }
     
    fn http_method(&self) -> String {
        self.method.clone()
    }

    fn http_headers(&self) -> Option<&HeaderMap> {
        Some(&self.headers)
    }
}

Required Methods§

Source

fn 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 route(&self) -> Option<String>

Returns the API Gateway resource pattern if available, otherwise None

Source

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

Returns pre-parsed path parameters if available

Source

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

Returns the query string

Source

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

Returns the client IP address

Source

fn http_headers(&self) -> Option<&HeaderMap>

Returns the request headers

Source

fn response_headers(&self) -> Option<&HeaderMap>

Returns the response headers

Source

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

Returns the user agent string

Source

fn url_scheme(&self) -> String

Returns the request scheme (http/https)

Source

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

Returns the server address

Source

fn server_port(&self) -> Option<u16>

Source

fn set_otel_http_attributes( &self, span: &Span, route_pattern: &str, lambda_context: &Context, )

Sets OpenTelemetry semantic convention attributes on the current span

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§