Documentation
¶
Overview ¶
Package middleware provides utilities to inject the response writer and request reader for the original *http.Request into the context and also retrieve it.
Index ¶
Constants ¶
const ResponseWriterKey responseWriterKey = "response-writer"
ResponseWriterKey is the context key for the response writer.
Variables ¶
This section is empty.
Functions ¶
func LoginCSRFCookieAliasMiddleware ¶ added in v0.18.0
LoginCSRFCookieAliasMiddleware maps a configured login-CSRF cookie name onto the canonical name that the generated OpenAPI handler reads (session.LoginCSRFCookieName, i.e. "__Host-LoginCSRF").
The generated callback handler hard-codes r.Cookie("__Host-LoginCSRF"), and the "__Host-" prefix requires the cookie's Secure attribute — which browsers reject over plain http://. Local development therefore needs a non-"__Host-" cookie name, but the read side cannot be changed. This middleware bridges the gap: when configuredName differs from the canonical name and only the configured cookie is present, it appends a copy under the canonical name so the downstream binder finds it.
It is a no-op when configuredName is empty or already equal to the canonical name, so production behavior is unchanged.
func ResponseWriterFromContext ¶
func ResponseWriterFromContext(ctx context.Context) (http.ResponseWriter, error)
ResponseWriterFromContext is a helper function that retrieves the response writer from the context.
Types ¶
This section is empty.