gotham-rs / gotham

A flexible web framework that promotes stability, safety, security and speed.
https://gotham.rs
Other
2.24k stars 125 forks source link

Create Path Extraction example #108

Closed bradleybeddoes closed 6 years ago

n-pochet commented 6 years ago

Hi, since I saw yesterday's PR #125 merge, I would like to try to make an example of it. I thought that at least something like this would be interesting:

GET localhost/myname
...

Hello, myname!

It is really straightforward to implement. @bradleybeddoes Did you think to something else?

bradleybeddoes commented 6 years ago

Sounds good, perhaps basic_path_extractor.

What I would like to do is try and unify the examples around what is currently shown in https://github.com/gotham-rs/gotham/blob/master/examples/basic_router/src/main.rs in terms of theme, that being a web store, which is hopefully a generic enough concept to assist folks in their learning of Gotham.

In this case how would you feel about the request being for /widgets/:name? (No need to replicate all routes shown in basic_router). The result body being something like format!("Product: {}", name).

The ultimate goal will be creation of a final example (at some point in the future), that combines all the concepts shown in all the previous examples, potentially in more advanced ways, leading to a basic, but functional, web store.