shiori/internal/model/http.go
Felipe Martin 1f309469c5
feat: reverts message in json output and allows configuration (#1082)
* 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
2025-03-16 19:09:28 +01:00

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
}