Replies: 1 comment
-
I don't think there's currently a way to do this. Yes, we've wanted the same thing for We added support for both structured and unstructured headers on successful responses in #283. We may want to do something similar here -- i.e., maybe the OpenAPI spec for the 401 response should say that it includes this header? I'm not sure. I believe this is where the error is turned into a response: dropshot/dropshot/src/server.rs Line 827 in 6151bb4 which calls: dropshot/dropshot/src/error.rs Lines 235 to 267 in 6151bb4 It'll take some thought to figure out how to best express this in a compatible way. |
Beta Was this translation helpful? Give feedback.
-
Hello and thanks for building this framework!
Is there a way to set a header on an
HttpError
from an endpoint? I don't see a way to do this, but I'm not sure if I'm just missing something. It would be useful at least in the case of returning a 401 UNAUTHORIZED response, which is supposed to include the WWW-AUTHENTICATE header. I think a workaround could be to create and return anErr(Response)
instead ofErr(HttpError)
, but there is a lot of convenience and consistency with usingHttpError
. I've dug a bit into the documentation and code and I'm not sure exactly where theHttpError
is turned into aResponse
(the documentation forHttpError
says "When these bubble up to the top of the request handling stack (which is most of the time that they’re generated), these are turned into an HTTP response"), but I think if aheaders
field (aVec
of&HeaderMap<HeaderValue>
) were added toHttpError
it could be handled/set there.Beta Was this translation helpful? Give feedback.
All reactions