Conversation
add `Created`, a helper type that forces the user to set a `Location` header when returning 201 CREATED
add `Created`, a helper type that forces the user to set a `Location` header when returning 201 CREATED
|
The doc comment mentions that 201 is recommended to have a
I don't see that as a recommendation to be honest, it just states, that if you send the header, it has special meaning but not that you SHOULD send it. |
|
Even though I read the part you mentioned to make this contribution, yeah it doesn't use the keyword which is probably an indicator you're right. Looking it up again though it says this under POST:
If you guys think this change is worth is is frankly up to you, I just wanted to get this out because I use it in my project and found it useful |
|
Right. In that case it does make sense but I think there should also be a way to explicitly create the response without the header. So I think having constructors like Maybe other maintainers will have different opinions though. |
can you even do at_request_path? Or do you mean like to give a URI as an argument? |
|
I meant it as with the implicit location, at which the resource was created, which is the request URI. The name I came up with might not be as clear as it should be.
|
|
Since this is trivial to write in user code with the semantics each user wants (I could see some always using it as a unit struct that always results in an empty body as another example), I'm inclined to not include this in axum. Thoughts? |
add
Created, a helper type that forces the user to set aLocationheader when returning 201 CREATEDMotivation
When looking at how to guarantee the CREATED status code's semantics I came up with this, maybe it's helpful.