Skip to content

How to handle subdomains #3103

Closed Answered by AeonSolstice
AeonSolstice asked this question in Q&A
Discussion options

You must be logged in to vote

I managed to solve it.

  1. Searched for wildcard in issues
  2. Found #1607 in closed issues
  3. Searched for Router.fallback() based on #1607 (comment)
  4. "Handling all requests without other routes"

Using Router::new().fallback(...) to accept all request regardless of path or method, if you don’t have other routes, isn’t optimal:
...
Running the handler directly is faster since it avoids the overhead of routing:

use axum::handler::HandlerWithoutStateExt;

async fn handler() {}

let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, handler.into_make_service()).await.unwrap();

New code (I did have to add the Router and axum::extract::Request types):

let ap…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@AeonSolstice
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by AeonSolstice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants