Skip to content

How to route unknown paths? #783

Description

@silvioprog

Hi.

I'm trying to write a reverse proxy example (#784), but I don't know how to route all possible paths. Consider the following example:

app.at("*") ... ;

now, take a look this tests below:

curl http://localhost:8080/test
ok
curl http://localhost:8080/
404
curl http://localhost:8080
404

Well, since wildcard allows anything, it should return ok in and / too. 😕

Thank you!

Activity

  1. jbr commented on Jan 24, 2021

    @jbr
    Member

    Is tide the right tool for a reverse proxy, vs using async-h1 directly?

  2. silvioprog commented on Jan 25, 2021

    @silvioprog
    Author

    @jbr It will be a naive simple example just to show how a tide-based server (instance) can handle reverse proxy.

  3. christoth commented on Jan 25, 2021

    @christoth

    I'm also trying to create a simple tide+surf based reverse-proxy.

    I experienced the same behaviour and while hoping for the same expected behaviour...

    The work-around I used was:
    app.at("/").all(move |mut client_request: Request<()>| async move { ... });
    app.at("*").all(move |mut client_request: Request<()>| async move { ... });

    That combination should route all your unknown paths.

  4. jbr commented on Jan 25, 2021

    @jbr
    Member

    Out of curiosity to understand this use case, do you have other routes in addition to these? If not, using tide will be slower than using async-h1 directly as a reverse proxy. If there is no reason to use tide itself, we probably shouldn't include an example that doesn't use the router or other tide-specific features

  5. Fishrock123 commented on Jan 26, 2021

    @Fishrock123
    Member

    This is useful for custom 404's. We should support this.

  6. christoth commented on Jan 27, 2021

    @christoth

    Thanks for the guidance!
    I'm working on an async-h1 reverse proxy example. It's pretty basic, as I'm learning Rust.

  7. spikecodes commented on Feb 4, 2021

    @spikecodes

    The reverse proxy example would be a great addition!

  8. jbr commented on Feb 4, 2021

    @jbr
    Member

    @spikecodes Which, a reverse proxy or * matching /?

  9. spikecodes commented on Feb 5, 2021

    @spikecodes

    My bad, I meant the reverse proxy example. I now see though that it's a separate PR: #784

  10. yoshuawuyts commented on Feb 12, 2021

    @yoshuawuyts
    Member

    This likely needs to be fixed in route-recognizer; I've filed an issue there: http-rs/route-recognizer#45.

  11. maxcountryman commented on Aug 10, 2021

    @maxcountryman

    Is there a preferred method for showing a 404 page when a route isn't found with Tide today?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions