-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify: respondWithStatus #18626
Comments
PS: Sorry if I'm too noisy with all these "clarify" tickets – It's mostly so we're able to respond properly once people coming from spray start asking "hey, X is missing!", and I'm noticing those currently since documenting all directives. I'm rather sure you made the right call when not porting something, just wanted to understand the reasoning behind it where it's not immediately clear to me 😄 Thanks in advance for the help! |
I didn't remember we once had this directive and I cannot remember a reason for not having ported it or making any decision. I think the main reason not to include it (despite seeming basic enough) would be that it isn't really useful in most cases. In most cases, you would first figure out the response status code before figuring out any other detail of the response, so the question would be why you would want to override it later on? Common ways to specify the status code are:
I'm not against include |
And, no worries about the clarify tickets. They are easier to keep track of than reading through the chat and better for keeping the record for later questions, so 👍 for having them. |
I agree with @jrudolph, keep the clarify tickets coming, Konrad! :) As to |
At the very least made it not recommended: /**
* Not recommended directive, try to solve your problem by providing a custom [[RejectionHandler]] for example.
*
* Overrides the response status code with the given one.
*/
def overrideStatusCode(responseStatus: StatusCode): Directive0 =
mapResponse(_.copy(status = responseStatus)) |
Ah those elusive little directives, I guess we probably just renamed it during the migration and no one could remember... Regarding the ScalaDoc maybe switch the lines around so that the summary is still at the top. That said, I wonder if we should keep it if we have only harsh words for it. Seems inconsequential and unfair to the little one. If we cannot find a positive description that would offer at least one however far-fetched use case for it, we should set it free. |
Trying to be inventive I imagined this use case: authorize(quotaOk) {
doThings()
} ~
overrideStatusCode(StatusCodes.EnhanceYourCalm) { // 420, e.g. used by Twitter
doThings()
} Not sure if that's realistic at all, rather not... 😉 |
It's still weird that you first build a full response just to get rid of it later on. |
Ok, since we can't find a good use case, I'll remove it. |
we don't recommend using it.
we don't recommend using it.
we don't recommend using it.
we don't recommend using it.
Hi @sirthias @jrudolph,
I realised we don't have
respondWithStatus
ported to Akka HTTP.On this one I'm not sure if it's an omission by design or accident, WDYT?
See:
Note to self ( remove
// FIXME https://github.com/akka/akka/issues/18626
from code once resolved )The text was updated successfully, but these errors were encountered: