Comments (11)
My use case, at the moment, is trying to implement CORS (before middleware support). I would like to have Options
and Get
(for example) to be handled by the same function so that I can handle the pre-flight and the actual requests without repeating some code.
from rocket.
It sounds like valid use cases. I agree it can be used to conflate ideas and easily abused. I think best some sort best practices or warning in the docs would helpful at addressing that, at least partially (since the most likely candidates to abuse the feature are newer users, the people who likely to be reading the docs).
from rocket.
Closing this as it seems unnecessary. Will revisit if requests call for it.
from rocket.
Additionally, allow the same argument to be used as both the query and form parameters if GET and POST are both present.
from rocket.
A workaround can be to simply place multiple attributes on the function:
#[get("/?<form>")]
#[post("/", form = "<form>")]
fn my_form() {
}
This won't work at the moment, of course, because the generated items will have the same name.
from rocket.
I'd like some feedback from others to determine if this feature is indeed worthwhile. I haven't had a need for it, and it seems to only conflate code and ideas. But if someone has a good use-case, I'm all ears.
from rocket.
Pushing this to a decision by 0.4.
from rocket.
I haven't had much use for this default behavior in Asp.Net MVC. I typically want it to be obvious where a request will be routed. I feel that Get/Post on the same handler function is more hassle than it's worth.
from rocket.
Routing both GET and POST to the same handler is very useful in a traditional web app that has a postback form.
An example in Flask (Python):
@app.route('/submit', methods=('GET', 'POST'))
def submit():
form = MyForm()
if form.validate_on_submit():
return redirect('/success')
return render_template('submit.html', form=form)
from rocket.
Those sound like valid use cases. Is there anyone that thinks this is a bad idea?
from rocket.
Pushing into the future.
from rocket.
Related Issues (20)
- New release of rocket_dyn_templates HOT 3
- Redirector issue in TLS example HOT 5
- Deployment Docs - Static Files HOT 1
- FromForm Option<Result> with custom type HOT 4
- Possible error in the Json guard HOT 3
- Allow Generics in route functions HOT 1
- Caching a background image with the `Cache-Control` header HOT 2
- sslmode=required not working for rocket_db_pool with feature diesel_postgres HOT 1
- Fairing returns incorrect Content-Length for status 204 HOT 7
- No way to turn off coloured log output HOT 2
- Implement derive FromParam for enum HOT 1
- Websockets (and any other connection upgrade) does not support local testing.
- `rocket_http` doesn't bulid/test on `rust` `1.80.0` HOT 1
- Expose the `tracing` layer construction to allow you to add other e.g. tracing_subscribers HOT 2
- Implement `PartialEq` for `http::Status` with derive macro HOT 4
- SQLx, Diesel, etc RUSTSEC tracking issue. HOT 2
- Request params fetch by name HOT 5
- Routes to paths with URL-encoded chars fails to match and always results in 404 HOT 1
- A new warning on rust beta: unreachable pattern HOT 2
- How should I save the Rocket logs to a file? HOT 2
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 rocket.