~lthms/typed-urls

ref: bb0b25803aea783924d68628c7b24130dcab34da typed-urls/src/actix.rs -rw-r--r-- 329 bytes
bb0b2580Thomas Letan Turn typed-urls-tera into a feature and introduce the actix feature 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use std::fmt::Display;

use actix_web::Resource;
use actix_web::web::resource;

use crate::TypedUrl;

pub trait Endpoint : TypedUrl {
    fn endpoint(route : Self::Route) -> Resource;
}

impl<U> Endpoint for U
where
    U : TypedUrl + Display
{
    fn endpoint(r : U::Route) -> Resource {
        resource(r.to_string())
    }
}