Documentation ¶
Index ¶
- Constants
- Variables
- func SetupCORSFilterByEnv(restContainer *restful.Container, envPrefix string) error
- type CORSFilterConfig
- type EmptyRequest
- type EmptyResponse
- type ErrorResponse
- type ErrorResponseField
- type HTTPReqInfo
- type LogFilter
- type LogServiceServer
- type LoggerBody
- type Recover
- type RecoveryService
- type RequestContext
- type Responder
- type ResponseCapture
- type StatsFilter
Constants ¶
View Source
const ( Base64 string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$" PrintableASCII string = "^[\x20-\x7E]+$" DataURI string = "^data:.+\\/(.+);base64$" Email string = "" /* 1212-byte string literal not displayed */ CreditCard string = "" /* 151-byte string literal not displayed */ PhoneNumber string = "" /* 182-byte string literal not displayed */ )
Variables ¶
View Source
var LoggerDefaultFormat = "{{.Status}} | ({{.IPAddr}}) {{.Hostname}} | {{.Method}} {{.Path}} {{if .Message}}:: {{.Message}}{{end}}"
LoggerDefaultFormat is the format logged used by the default Logger instance.
View Source
var SafeFields = []string{"authorization", "api-key", "api", "apikey", "merchant-key", "enterprise-token", "token", "user-token"}
Functions ¶
func SetupCORSFilterByEnv ¶
Types ¶
type CORSFilterConfig ¶
type CORSFilterConfig struct { AllowedHeaders *string `env:"ALLOWED_HEADERS"` AllowedMethods string `env:"ALLOWED_METHODS"` AllowedDomains string `env:"ALLOWED_DOMAINS"` }
CORSFilterConfig get cors filter from env AllowedHeaders define which headers is allowed AllowedMethods define which http methods is allowed AllowedDomains define which domain is allowd or set to (*)
type EmptyRequest ¶
type EmptyRequest struct{}
type EmptyResponse ¶
type EmptyResponse struct{}
type ErrorResponse ¶
type ErrorResponse struct { // Code this will be used as error code Code string `json:"code,omitempty"` // We use the term description because it describes the error // to the developer rather than a message for the end user. Description string `json:"description,omitempty"` Fields []ErrorResponseField `json:"fields,omitempty"` DocURL string `json:"doc_url,omitempty"` }
type ErrorResponseField ¶
type HTTPReqInfo ¶
type LogFilter ¶
type LogFilter struct {
// contains filtered or unexported fields
}
func NewRequestLoggingFilter ¶
func NewRequestLoggingFilter(logSrv LogServiceServer) *LogFilter
type LogServiceServer ¶
type LoggerBody ¶
type LoggerBody struct { Header propertyMap `json:"header,omitempty"` Request propertyMap `json:"request,omitempty"` Response propertyMap `json:"response,omitempty"` }
type Recover ¶
type Recover struct { StackAll bool StackSize int PrintStack bool // contains filtered or unexported fields }
func NewRecoveryFilter ¶
func NewRecoveryFilter(svc RecoveryService) *Recover
func (*Recover) RecoverOnPanic ¶
func (rec *Recover) RecoverOnPanic(panicReason any, httpWriter http.ResponseWriter)
type RecoveryService ¶
type RequestContext ¶
type RequestContext interface { api.CallContext HTTPRequest() *http.Request }
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
func RespondTo ¶
func RespondTo(w http.ResponseWriter) Responder
func (Responder) EmptyError ¶
func (Responder) SuccessWithHTTPStatusCode ¶
type ResponseCapture ¶
type ResponseCapture struct { http.ResponseWriter // contains filtered or unexported fields }
func NewResponseCapture ¶
func NewResponseCapture(w http.ResponseWriter) *ResponseCapture
func (ResponseCapture) Bytes ¶
func (c ResponseCapture) Bytes() []byte
func (ResponseCapture) Header ¶
func (c ResponseCapture) Header() http.Header
func (ResponseCapture) StatusCode ¶
func (c ResponseCapture) StatusCode() int
func (*ResponseCapture) WriteHeader ¶
func (c *ResponseCapture) WriteHeader(statusCode int)
type StatsFilter ¶
type StatsFilter struct {
// contains filtered or unexported fields
}
func NewStatsFilter ¶
func NewStatsFilter() *StatsFilter
func (*StatsFilter) Filter ¶
func (sf *StatsFilter) Filter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
func (*StatsFilter) StatsHandler ¶
func (sf *StatsFilter) StatsHandler(w http.ResponseWriter, r *http.Request)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.