Replies: 1 comment 3 replies
-
This is a problem that should be solved by an old-fashioned http4s middleware. The smithy4s endpoint specific middleware operates at a different level, once a request have matched a specific endpoint. If your user get a All you need is roughly : def change404[F[_] : MonadThrow](app : HttpApp[F]): HttpApp[F] = HttpApp.of[F] { req =>
app.run(req).flatMap { response =>
// if response status code is 404 then change response
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
with the http4s
SimpleRestJsonBuilder
I want to return a customNotFoundError
so I added the following middleware:This is of course technically incorrect as it recovers from all internal errors not just the cases where the request can't be matched against any smithy generated routes
Note that
SimpleRestJsonBuilder.routes(...).resources
gives meHttpRoutes
as opposed toHttpApp
, so when I put the service together I have no choice but to then addroute.orNotFound
.I'd have expected the middleware to pick up the
NotFound
but I still get the defaultNot Found
response from http4s itself.So that doesn't work. any potential other ways I could do this?
Beta Was this translation helpful? Give feedback.
All reactions