api

package
v2.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxContentDispositionHeaderFilenameLength = 256
	DefaultAttachmentFilename                 = "attachment"
)

Variables

View Source
var ErrRangeHeaderInvalid = errors.New("Invalid Range header")

Functions

func AccessControlMiddleware

func AccessControlMiddleware(next http.Handler) http.Handler

func LogMiddleware

func LogMiddleware(next http.Handler) http.Handler

func NewPath

func NewPath(escaped string) *url.URL

func RequestMiddleware

func RequestMiddleware(next http.Handler) http.Handler

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 SetPageQuery

func SetPageQuery(out url.Values, r *http.Request)

func SetQuery

func SetQuery(u *url.URL, r *http.Request, fns ...SetQueryFunc)

func WriteError

func WriteError(ctx context.Context, w http.ResponseWriter, err errors.Error)

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 Cacheable

type Cacheable interface {
	CacheKey() (string, bool)
}

type ConditionalResolver

type ConditionalResolver interface {
	Accept(ctx context.Context, w http.ResponseWriter, c Cacheable) bool
}

func NewConditionalResolver

func NewConditionalResolver(r *http.Request) ConditionalResolver

type ETag

type ETag struct {
	Weak  bool
	Value string
}

func (ETag) String

func (et ETag) String() string

type ErrorEnvelope

type ErrorEnvelope struct {
	Error *encoding.ErrorDisplayEnvelope `json:"error"`
}

func NewErrorEnvelope

func NewErrorEnvelope(err errors.Error) *ErrorEnvelope

type Page

type Page interface {
	Offset() string
	Limit() int
}

func FirstPage

func FirstPage(limit int) Page

func NewPage

func NewPage(offset string, limit int) Page

func NewPageFromRequest

func NewPageFromRequest(r *http.Request, defaultLimit int) Page

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

type RangeHeader struct {
	Unit  string // always "bytes" for now
	Specs []RangeSpec
}

func ScanRangeHeader

func ScanRangeHeader(header string) (*RangeHeader, error)

type RangeSpec

type RangeSpec struct {
	First *int64
	Last  *int64
	// If non-null First/Last are null.
	SuffixLength *int64
}

type SetQueryFunc

type SetQueryFunc func(out url.Values, in *http.Request)

type TrackingResponseWriter

type TrackingResponseWriter interface {
	http.ResponseWriter

	StatusCode() (int, bool)
	Committed() bool
}

func NewTrackingResponseWriter

func NewTrackingResponseWriter(delegate http.ResponseWriter) TrackingResponseWriter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL