Replies: 1 comment 2 replies
-
ctx.response.setCookie("session", { secure: true, ... }) So basically:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are a few decisions to make:
(req, ctx) => Response | undefined
. Ifundefined
is returned, next middleware is run. You can change req and ctx fields to do useful stuff (e.g. parse cookies and pur it inctx.cookies
).(req, ctx, next) => Response
.next
gives you the ability to manipulate the response, e.g. add security headers but it's more awkward to use.undefined
does the same thing asreturn next()
. Fatih's preferencectx.response("body").type("application/html").cookie("session", { secure: true, ... })
build()
:return builder().xxx().yyy().build()
(so that it returns aResponse
instance instead of a builder instance).toResponse()
method in addition to plainResponse
. Fatih's preferencetry/catch
or do things likereturn next().catch(error => ...)
. We only provide a last resort 500 response.ctx.addErrorHandler()
, handlers are called (last added first) until one handles the error and returns a response.toResponse()
method: It makes validation errors very easy to handle (just implementMyValidationLibraryError.prototype.toResponse
. Also allows "throwing" responses (useful in some cases).Beta Was this translation helpful? Give feedback.
All reactions