Comments (3)
from poem.
This is an example of using multiple path parameters, Path((name, age)): Path<(String, u32)>, where name and age need to be placed in a tuple instead of two parameters
#[handler]
fn hello(Path((name, age)): Path<(String, u32)>) -> String {
format!("hello: {name}, {age}", name = name, age = age)
}
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
if std::env::var_os("RUST_LOG").is_none() {
std::env::set_var("RUST_LOG", "poem=debug");
}
tracing_subscriber::fmt::init();
let app = Route::new()
.at("/hello/:name/:age", get(hello))
.with(Tracing);
Server::new(TcpListener::bind("0.0.0.0:3000"))
.name("hello-world")
.run(app)
.await
}
from poem.
This works, but I'm unclear about why some endpoints can use multiple path parameters, but this one cannot.
from poem.
Related Issues (20)
- Middleware examples are out of date
- EmbeddedFilesEndpoint not working for index.html in subdirectory HOT 2
- [poem-openapi] Path parameters in `prefix_path` do not generate the correct openapi specification HOT 1
- Redirect response type error HOT 1
- RequestId Middleware display ERROR Message
- The api doc request response 502 when set the host `0.0.0.0` HOT 2
- Advanced mTLS support
- Correct usage of `CookieJar`, `private` and `private_with_key` HOT 1
- Grpc Build: Format service name as `.{proto_name}` when package is empty
- serve_connection should handle panic?
- Drop `#[derive(Default)]` from handler macro HOT 2
- Merging api specs/different middleware's for different apis with same OpenAPI Specificaton
- GRPC over unix domain socket
- How to get nested objects when retrieving query parameters with Query?
- How to use Rust WebDAV with poem
- Error handling with multiple security schemes is inconsitant
- Is `skip_serializing_if_is_none` working as expected? HOT 2
- Type for an Acceptor that maybe TLS or not HOT 2
- Poem GRPC does not work behind traefik proxy when compression middleware is enabled HOT 1
- How to nest route with path param? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poem.