Documentation ¶
Index ¶
- Variables
- func ConflictError(w http.ResponseWriter, message string)
- func ContextInjector(componentName string, handler http.Handler) http.Handler
- func DecodeJSON(req *http.Request, i interface{}) error
- func Error(w http.ResponseWriter, err error)
- func IsObjectExistsError(err error) bool
- func IsObjectNotFoundError(err error) bool
- func IsPreconditionFailedError(err error) bool
- func IsRetryableError(err error) bool
- func IsValidationError(err error) bool
- func JSON(w http.ResponseWriter, status int, v interface{})
- func NewRequestLogger(handler http.Handler) http.Handler
- func NewRequestLoggerCustom(handler http.Handler, loggerFn RequestLoggerFn) http.Handler
- func ObjectExistsErr(message string) error
- func ObjectExistsError(w http.ResponseWriter, message string)
- func ObjectNotFoundError(w http.ResponseWriter, message string)
- func PreconditionFailedErr(message string) error
- func ServiceUnavailableError(w http.ResponseWriter, message string)
- func ValidationError(w http.ResponseWriter, field, message string)
- func WrapHandler(handler HandlerFunc) httprouter.Handle
- type ErrorCode
- type FlushWriter
- type Handler
- type HandlerFunc
- type JSONError
- type RequestLoggerFn
- type ResponseWriter
- func (r *ResponseWriter) CloseNotify() <-chan bool
- func (r *ResponseWriter) Context() context.Context
- func (r *ResponseWriter) Flush()
- func (r *ResponseWriter) Header() http.Header
- func (r *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (r *ResponseWriter) Status() int
- func (r *ResponseWriter) Write(b []byte) (int, error)
- func (r *ResponseWriter) WriteHeader(s int)
- func (r *ResponseWriter) Written() bool
Constants ¶
This section is empty.
Variables ¶
View Source
var CORSAllowAll = &cors.Options{ AllowAllOrigins: true, AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"}, AllowHeaders: []string{"Authorization", "Accept", "Content-Type", "If-Match", "If-None-Match"}, ExposeHeaders: []string{"ETag", "Content-Disposition"}, AllowCredentials: true, MaxAge: time.Hour, }
Functions ¶
func ConflictError ¶
func ConflictError(w http.ResponseWriter, message string)
func ContextInjector ¶
func DecodeJSON ¶
func Error ¶
func Error(w http.ResponseWriter, err error)
func IsObjectExistsError ¶
func IsObjectNotFoundError ¶
func IsRetryableError ¶
IsRetryableError indicates whether a HTTP request can be safely retried.
func IsValidationError ¶
func JSON ¶
func JSON(w http.ResponseWriter, status int, v interface{})
func NewRequestLoggerCustom ¶
func NewRequestLoggerCustom(handler http.Handler, loggerFn RequestLoggerFn) http.Handler
func ObjectExistsErr ¶
func ObjectExistsError ¶
func ObjectExistsError(w http.ResponseWriter, message string)
func ObjectNotFoundError ¶
func ObjectNotFoundError(w http.ResponseWriter, message string)
func PreconditionFailedErr ¶
func ServiceUnavailableError ¶
func ServiceUnavailableError(w http.ResponseWriter, message string)
func ValidationError ¶
func ValidationError(w http.ResponseWriter, field, message string)
func WrapHandler ¶
func WrapHandler(handler HandlerFunc) httprouter.Handle
Types ¶
type ErrorCode ¶
type ErrorCode string
const ( NotFoundErrorCode ErrorCode = "not_found" ObjectNotFoundErrorCode ErrorCode = "object_not_found" ObjectExistsErrorCode ErrorCode = "object_exists" ConflictErrorCode ErrorCode = "conflict" SyntaxErrorCode ErrorCode = "syntax_error" ValidationErrorCode ErrorCode = "validation_error" PreconditionFailedErrorCode ErrorCode = "precondition_failed" UnknownErrorCode ErrorCode = "unknown_error" RatelimitedErrorCode ErrorCode = "ratelimited" )
type FlushWriter ¶
type Handler ¶
Handler is an extended version of http.Handler that also takes a context argument ctx.
type HandlerFunc ¶
The HandlerFunc type is an adapter to allow the use of ordinary functions as Handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler object that calls f.
func (HandlerFunc) ServeHTTP ¶
func (f HandlerFunc) ServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request)
ServeHTTP calls f(ctx, w, r).
type JSONError ¶
type JSONError struct { Code ErrorCode `json:"code"` Message string `json:"message"` Detail json.RawMessage `json:"detail,omitempty"` Retry bool `json:"retry"` }
type RequestLoggerFn ¶
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter, ctx context.Context) *ResponseWriter
func (*ResponseWriter) CloseNotify ¶
func (r *ResponseWriter) CloseNotify() <-chan bool
func (*ResponseWriter) Context ¶
func (r *ResponseWriter) Context() context.Context
func (*ResponseWriter) Flush ¶
func (r *ResponseWriter) Flush()
func (*ResponseWriter) Header ¶
func (r *ResponseWriter) Header() http.Header
func (*ResponseWriter) Hijack ¶
func (r *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*ResponseWriter) Status ¶
func (r *ResponseWriter) Status() int
func (*ResponseWriter) WriteHeader ¶
func (r *ResponseWriter) WriteHeader(s int)
func (*ResponseWriter) Written ¶
func (r *ResponseWriter) Written() bool
Click to show internal directories.
Click to hide internal directories.