tomaka / rouille

Web framework in Rust
Apache License 2.0
1.09k stars 105 forks source link

`router!` macro expansion appears inefficient. #278

Open pnathan opened 9 months ago

pnathan commented 9 months ago

router! macro expansion appears inefficient.

Hi, when I do an expand of router!, I see a number of outputs that look like this. Shouldn't this be, ultimately, a string compare?

    {
        if ret.is_none() && request.method() == stringify!( POST ) {
            ret = {
                let required = concat!( "/", stringify!( api ) );
                if let Some(rest_url) = request_url.strip_prefix(required) {
                    {
                        let required = concat!( "/", stringify!( v1 ) );
                        if let Some(rest_url) = rest_url.strip_prefix(required) {
                            {
                                let required = concat!( "/", stringify!( domain ) );
                                if let Some(rest_url) = rest_url.strip_prefix(required) {

I'm more than happy to use an interface that looks like

server.add_handler("/api/v1/domain", method::POST, domain_handler_post)