mirror of
https://github.com/go-shiori/shiori.git
synced 2025-09-12 16:04:57 +08:00
* feat: allow future deprecated message response with config * tests: middleware * fix: middleware order * fix: frontend using message in body * fix: cors * feat: modify response type with header * fix(webapp): added new headers * dist: updated webapp files * test(e2e): fixes * fix: middleware returning body for 204 requests * fix: frontend apis * tests: cors middleware
34 lines
1 KiB
Go
34 lines
1 KiB
Go
package model
|
|
|
|
import "net/http"
|
|
|
|
const (
|
|
// ContextAccountKey is the key used to store the account model in the gin context.
|
|
ContextAccountKey = "account"
|
|
|
|
// AuthorizationHeader is the name of the header used to send the token.
|
|
AuthorizationHeader = "Authorization"
|
|
// AuthorizationTokenType is the type of token used in the Authorization header.
|
|
AuthorizationTokenType = "Bearer"
|
|
)
|
|
|
|
// WebContext represents the context of an HTTP request
|
|
type WebContext interface {
|
|
Request() *http.Request
|
|
ResponseWriter() http.ResponseWriter
|
|
SetResponseWriter(w http.ResponseWriter)
|
|
GetAccount() *AccountDTO
|
|
SetAccount(*AccountDTO)
|
|
UserIsLogged() bool
|
|
GetRequestID() string
|
|
SetRequestID(id string)
|
|
}
|
|
|
|
// Handler is a custom handler function that receives dependencies and web context
|
|
type HttpHandler func(deps Dependencies, c WebContext)
|
|
|
|
// Middleware defines the interface for request/response customization
|
|
type HttpMiddleware interface {
|
|
OnRequest(deps Dependencies, c WebContext) error
|
|
OnResponse(deps Dependencies, c WebContext) error
|
|
}
|