pub trait RouteFormatter: Debug {
    // Required method
    fn format(&self, path: &str) -> String;
}
Expand description

Interface for formatting routes from paths.

This crate will render the actix web match pattern by default. E.g. for path /users/123/profile the route for this span would be /users/{id}/profile.

§Custom Formatter Examples

use unleash_edge::metrics::route_formatter::RouteFormatter;

// A formatter to ensure all paths are reported as lowercase.
#[derive(Debug)]
struct MyLowercaseFormatter;

impl RouteFormatter for MyLowercaseFormatter {
    fn format(&self, path: &str) -> String {
        path.to_lowercase()
    }
}

// now a match with pattern `/USERS/{id}` would be recorded as `/users/{id}`

Required Methods§

source

fn format(&self, path: &str) -> String

Function from path to route. e.g. /users/123 -> /users/:id

Implementors§