Documentation ¶
Index ¶
- Constants
- Variables
- func AccessControlMiddleware(next http.Handler) http.Handler
- func LogMiddleware(next http.Handler) http.Handler
- func NewPath(escaped string) *url.URL
- func RequestMiddleware(next http.Handler) http.Handler
- func SetContentDispositionHeader(w http.ResponseWriter, filename string)
- func SetPageQuery(out url.Values, r *http.Request)
- func SetQuery(u *url.URL, r *http.Request, fns ...SetQueryFunc)
- func WriteError(ctx context.Context, w http.ResponseWriter, err errors.Error)
- func WriteObjectCreated(ctx context.Context, w http.ResponseWriter, object interface{})
- func WriteObjectOK(ctx context.Context, w http.ResponseWriter, object interface{})
- func WriteObjectWithStatus(ctx context.Context, w http.ResponseWriter, status int, object interface{})
- func WriteRedirect(w http.ResponseWriter, u *url.URL)
- type CORSBuilder
- type Cacheable
- type ConditionalResolver
- type ETag
- type ErrorEnvelope
- type Page
- type RangeError
- type RangeErrorCode
- type RangeHeader
- type RangeSpec
- type SetQueryFunc
- type TrackingResponseWriter
Constants ¶
View Source
const ( MaxContentDispositionHeaderFilenameLength = 256 DefaultAttachmentFilename = "attachment" )
Variables ¶
View Source
var ErrRangeHeaderInvalid = errors.New("Invalid Range header")
Functions ¶
func SetContentDispositionHeader ¶
func SetContentDispositionHeader(w http.ResponseWriter, filename string)
SetContentDispositionHeader cleans the given filename, setting the sanitized name in the response as the Content-Disposition header filename value.
Content-Disposition is so hard to get right that there's an entire RFC dedicated to it [https://tools.ietf.org/html/rfc6266]. It is recommended to just use this function and accept the resulting filename rather than trying to customize anything.
func WriteError ¶
func WriteObjectCreated ¶
func WriteObjectCreated(ctx context.Context, w http.ResponseWriter, object interface{})
func WriteObjectOK ¶
func WriteObjectOK(ctx context.Context, w http.ResponseWriter, object interface{})
func WriteObjectWithStatus ¶
func WriteObjectWithStatus(ctx context.Context, w http.ResponseWriter, status int, object interface{})
func WriteRedirect ¶
func WriteRedirect(w http.ResponseWriter, u *url.URL)
Types ¶
type CORSBuilder ¶
type CORSBuilder struct {
// contains filtered or unexported fields
}
func NewCORSBuilder ¶
func NewCORSBuilder() *CORSBuilder
func (*CORSBuilder) AllowHeaderPrefix ¶
func (cb *CORSBuilder) AllowHeaderPrefix(prefix string) *CORSBuilder
func (*CORSBuilder) AllowHeaders ¶
func (cb *CORSBuilder) AllowHeaders(headers ...string) *CORSBuilder
func (*CORSBuilder) AllowMethods ¶
func (cb *CORSBuilder) AllowMethods(methods ...string) *CORSBuilder
func (*CORSBuilder) Build ¶
func (cb *CORSBuilder) Build() http.Handler
type ConditionalResolver ¶
type ConditionalResolver interface {
Accept(ctx context.Context, w http.ResponseWriter, c Cacheable) bool
}
func NewConditionalResolver ¶
func NewConditionalResolver(r *http.Request) ConditionalResolver
type ErrorEnvelope ¶
type ErrorEnvelope struct {
Error *encoding.ErrorDisplayEnvelope `json:"error"`
}
func NewErrorEnvelope ¶
func NewErrorEnvelope(err errors.Error) *ErrorEnvelope
type RangeError ¶
type RangeError struct { Code RangeErrorCode Message string }
func (*RangeError) Error ¶
func (e *RangeError) Error() string
type RangeErrorCode ¶
type RangeErrorCode string
const ( InvalidRangeHeader RangeErrorCode = "InvalidRangeHeader" UnsupportedRangeUnit RangeErrorCode = "UnsupportedRangeUnit" UnsatisfiableRange RangeErrorCode = "UnsatisfiableRange" )
type RangeHeader ¶
func ScanRangeHeader ¶
func ScanRangeHeader(header string) (*RangeHeader, error)
type TrackingResponseWriter ¶
type TrackingResponseWriter interface { http.ResponseWriter StatusCode() (int, bool) Committed() bool }
func NewTrackingResponseWriter ¶
func NewTrackingResponseWriter(delegate http.ResponseWriter) TrackingResponseWriter
Click to show internal directories.
Click to hide internal directories.