Documentation ¶
Index ¶
- Constants
- func ClientIP(r *http.Request) string
- func ClientIPByHeaderForwardedFor(headerForwardedFor string) string
- func ClientIPByHeaderRealIP(headerRealIP string) string
- func Metadata(key string, values ...string) courier.Metadata
- type ApplicationOgg
- type Attachment
- type AudioMidi
- type AudioMp3
- type AudioOgg
- type AudioWave
- type AudioWebm
- type CSS
- type ContentTypeDescriber
- type CookiesDescriber
- type HTML
- type ImageBmp
- type ImageGIF
- type ImageJPEG
- type ImagePNG
- type ImageSVG
- type ImageWebp
- type MethodConnect
- type MethodDelete
- type MethodGet
- type MethodHead
- type MethodOptions
- type MethodPatch
- type MethodPost
- type MethodPut
- type MethodTrace
- type Plain
- type RedirectDescriber
- type Response
- type ResponseWrapper
- type StatusCodeDescriber
- type StatusFound
- type StatusMovedPermanently
- type StatusMultipleChoices
- type StatusNotModified
- type StatusPermanentRedirect
- type StatusSeeOther
- type StatusTemporaryRedirect
- type StatusUseProxy
- type Upgrader
- type VideoOgg
- type VideoWebm
Examples ¶
- ApplicationOgg
- AudioMidi
- AudioMp3
- AudioOgg
- AudioWave
- AudioWebm
- CSS
- HTML
- ImageBmp
- ImageGIF
- ImageJPEG
- ImagePNG
- ImageSVG
- ImageWebp
- MethodConnect
- MethodDelete
- MethodGet
- MethodHead
- MethodOptions
- MethodPatch
- MethodPost
- MethodPut
- MethodTrace
- NewAttachment
- Plain
- StatusFound
- StatusMovedPermanently
- StatusMultipleChoices
- StatusNotModified
- StatusPermanentRedirect
- StatusSeeOther
- StatusTemporaryRedirect
- StatusUseProxy
- VideoOgg
- VideoWebm
Constants ¶
View Source
const ( HeaderUserAgent = "User-Agent" HeaderContentType = "Content-Type" HeaderContentDisposition = "Content-Disposition" HeaderRequestID = "X-Request-ID" HeaderForwardedFor = "X-Forwarded-For" HeaderRealIP = "X-Real-IP" )
View Source
const ( MIME_OCTET_STREAM = "application/octet-stream" MIME_JSON = "application/json" MIME_XML = "application/xml" MIME_FORM_URLENCODED = "application/x-www-form-urlencoded" MIME_MULTIPART_FORMDAT = "multipart/form-data" MIME_PROTOBUF = "application/x-protobuf" MIME_MSGPACK = "application/x-msgpack" )
Variables ¶
This section is empty.
Functions ¶
func ClientIPByHeaderForwardedFor ¶
X-Forwarded-For: client, proxy1, proxy2 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
func ClientIPByHeaderRealIP ¶
X-Forwarded-For: client, proxy1, proxy2 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
Types ¶
type ApplicationOgg ¶
Example ¶
m := NewApplicationOgg() fmt.Println(m.ContentType())
Output: application/ogg
func NewApplicationOgg ¶
func NewApplicationOgg() *ApplicationOgg
func (ApplicationOgg) ContentType ¶
func (ApplicationOgg) ContentType() string
type Attachment ¶
func NewAttachment ¶
func NewAttachment(filename string, contentType string) *Attachment
Example ¶
a := NewAttachment("test.txt", MIME_JSON) a.WriteString("{}") fmt.Println(a.ContentType()) fmt.Println(a.Meta()) fmt.Println(a.String())
Output: application/json Content-Disposition=attachment%3B+filename%3Dtest.txt {}
func (*Attachment) ContentType ¶
func (a *Attachment) ContentType() string
func (*Attachment) Meta ¶
func (a *Attachment) Meta() courier.Metadata
type AudioMidi ¶
Example ¶
m := NewAudioMidi() fmt.Println(m.ContentType())
Output: audio/midi
func NewAudioMidi ¶
func NewAudioMidi() *AudioMidi
func (AudioMidi) ContentType ¶
type AudioMp3 ¶
Example ¶
m := NewAudioMp3() fmt.Println(m.ContentType())
Output: audio/mpeg
func NewAudioMp3 ¶
func NewAudioMp3() *AudioMp3
func (AudioMp3) ContentType ¶
type AudioOgg ¶
Example ¶
m := NewAudioOgg() fmt.Println(m.ContentType())
Output: audio/ogg
func NewAudioOgg ¶
func NewAudioOgg() *AudioOgg
func (AudioOgg) ContentType ¶
type AudioWave ¶
Example ¶
m := NewAudioWave() fmt.Println(m.ContentType())
Output: audio/wav
func NewAudioWave ¶
func NewAudioWave() *AudioWave
func (AudioWave) ContentType ¶
type AudioWebm ¶
Example ¶
m := NewAudioWebm() fmt.Println(m.ContentType())
Output: audio/webm
func NewAudioWebm ¶
func NewAudioWebm() *AudioWebm
func (AudioWebm) ContentType ¶
type CSS ¶
Example ¶
m := NewCSS() fmt.Println(m.ContentType())
Output: text/css
func (CSS) ContentType ¶
type ContentTypeDescriber ¶
type ContentTypeDescriber interface {
ContentType() string
}
type CookiesDescriber ¶
type HTML ¶
Example ¶
m := NewHTML() fmt.Println(m.ContentType())
Output: text/html
func (HTML) ContentType ¶
type ImageBmp ¶
Example ¶
m := NewImageBmp() fmt.Println(m.ContentType())
Output: image/bmp
func NewImageBmp ¶
func NewImageBmp() *ImageBmp
func (ImageBmp) ContentType ¶
type ImageGIF ¶
Example ¶
m := NewImageGIF() fmt.Println(m.ContentType())
Output: image/gif
func NewImageGIF ¶
func NewImageGIF() *ImageGIF
func (ImageGIF) ContentType ¶
type ImageJPEG ¶
Example ¶
m := NewImageJPEG() fmt.Println(m.ContentType())
Output: image/jpeg
func NewImageJPEG ¶
func NewImageJPEG() *ImageJPEG
func (ImageJPEG) ContentType ¶
type ImagePNG ¶
Example ¶
m := NewImagePNG() fmt.Println(m.ContentType())
Output: image/png
func NewImagePNG ¶
func NewImagePNG() *ImagePNG
func (ImagePNG) ContentType ¶
type ImageSVG ¶
Example ¶
m := NewImageSVG() fmt.Println(m.ContentType())
Output: image/svg+xml
func NewImageSVG ¶
func NewImageSVG() *ImageSVG
func (ImageSVG) ContentType ¶
type ImageWebp ¶
Example ¶
m := NewImageWebp() fmt.Println(m.ContentType())
Output: image/webp
func NewImageWebp ¶
func NewImageWebp() *ImageWebp
func (ImageWebp) ContentType ¶
type MethodConnect ¶
type MethodConnect struct{}
Example ¶
m := MethodConnect{} fmt.Println(m.Method())
Output: CONNECT
func (MethodConnect) Method ¶
func (MethodConnect) Method() string
type MethodDelete ¶
type MethodDelete struct{}
Example ¶
m := MethodDelete{} fmt.Println(m.Method())
Output: DELETE
func (MethodDelete) Method ¶
func (MethodDelete) Method() string
type MethodGet ¶
type MethodGet struct{}
Example ¶
m := MethodGet{} fmt.Println(m.Method())
Output: GET
type MethodHead ¶
type MethodHead struct{}
Example ¶
m := MethodHead{} fmt.Println(m.Method())
Output: HEAD
func (MethodHead) Method ¶
func (MethodHead) Method() string
type MethodOptions ¶
type MethodOptions struct{}
Example ¶
m := MethodOptions{} fmt.Println(m.Method())
Output: OPTIONS
func (MethodOptions) Method ¶
func (MethodOptions) Method() string
type MethodPatch ¶
type MethodPatch struct{}
Example ¶
m := MethodPatch{} fmt.Println(m.Method())
Output: PATCH
func (MethodPatch) Method ¶
func (MethodPatch) Method() string
type MethodPost ¶
type MethodPost struct{}
Example ¶
m := MethodPost{} fmt.Println(m.Method())
Output: POST
func (MethodPost) Method ¶
func (MethodPost) Method() string
type MethodPut ¶
type MethodPut struct{}
Example ¶
m := MethodPut{} fmt.Println(m.Method())
Output: PUT
type MethodTrace ¶
type MethodTrace struct{}
Example ¶
m := MethodTrace{} fmt.Println(m.Method())
Output: TRACE
func (MethodTrace) Method ¶
func (MethodTrace) Method() string
type Plain ¶
Example ¶
m := NewPlain() fmt.Println(m.ContentType())
Output: text/plain
func (Plain) ContentType ¶
type RedirectDescriber ¶
type RedirectDescriber interface { StatusCodeDescriber Location() *url.URL }
type Response ¶
type Response struct { // value of Body Value interface{} Metadata courier.Metadata Cookies []*http.Cookie Location *url.URL ContentType string StatusCode int }
func ResponseFrom ¶
func ResponseFrom(v interface{}) *Response
type ResponseWrapper ¶
type ResponseWrapper func(v interface{}) *Response
func Compose ¶
func Compose(responseWrappers ...ResponseWrapper) ResponseWrapper
func WithContentType ¶
func WithContentType(contentType string) ResponseWrapper
func WithCookies ¶
func WithCookies(cookies ...*http.Cookie) ResponseWrapper
func WithMetadata ¶
func WithMetadata(metadatas ...courier.Metadata) ResponseWrapper
func WithStatusCode ¶
func WithStatusCode(statusCode int) ResponseWrapper
type StatusCodeDescriber ¶
type StatusCodeDescriber interface {
StatusCode() int
}
type StatusFound ¶
type StatusFound struct {
// contains filtered or unexported fields
}
Example ¶
m := RedirectWithStatusFound(&(net_url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) fmt.Println(m.Error())
Output: 302 /test Location: /test
func RedirectWithStatusFound ¶
func RedirectWithStatusFound(u *net_url.URL) *StatusFound
func (StatusFound) StatusCode ¶
func (StatusFound) StatusCode() int
type StatusMovedPermanently ¶
type StatusMovedPermanently struct {
// contains filtered or unexported fields
}
Example ¶
m := RedirectWithStatusMovedPermanently(&(net_url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) fmt.Println(m.Error())
Output: 301 /test Location: /test
func RedirectWithStatusMovedPermanently ¶
func RedirectWithStatusMovedPermanently(u *net_url.URL) *StatusMovedPermanently
func (StatusMovedPermanently) Error ¶
func (r StatusMovedPermanently) Error() string
Redirect could be an error
func (StatusMovedPermanently) StatusCode ¶
func (StatusMovedPermanently) StatusCode() int
type StatusMultipleChoices ¶
type StatusMultipleChoices struct {
// contains filtered or unexported fields
}
Example ¶
m := RedirectWithStatusMultipleChoices(&(net_url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) fmt.Println(m.Error())
Output: 300 /test Location: /test
func RedirectWithStatusMultipleChoices ¶
func RedirectWithStatusMultipleChoices(u *net_url.URL) *StatusMultipleChoices
func (StatusMultipleChoices) Error ¶
func (r StatusMultipleChoices) Error() string
Redirect could be an error
func (StatusMultipleChoices) StatusCode ¶
func (StatusMultipleChoices) StatusCode() int
type StatusNotModified ¶
type StatusNotModified struct {
// contains filtered or unexported fields
}
Example ¶
m := RedirectWithStatusNotModified(&(net_url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) fmt.Println(m.Error())
Output: 304 /test Location: /test
func RedirectWithStatusNotModified ¶
func RedirectWithStatusNotModified(u *net_url.URL) *StatusNotModified
func (StatusNotModified) Error ¶
func (r StatusNotModified) Error() string
Redirect could be an error
func (StatusNotModified) StatusCode ¶
func (StatusNotModified) StatusCode() int
type StatusPermanentRedirect ¶
type StatusPermanentRedirect struct {
// contains filtered or unexported fields
}
Example ¶
m := RedirectWithStatusPermanentRedirect(&(net_url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) fmt.Println(m.Error())
Output: 308 /test Location: /test
func RedirectWithStatusPermanentRedirect ¶
func RedirectWithStatusPermanentRedirect(u *net_url.URL) *StatusPermanentRedirect
func (StatusPermanentRedirect) Error ¶
func (r StatusPermanentRedirect) Error() string
Redirect could be an error
func (StatusPermanentRedirect) StatusCode ¶
func (StatusPermanentRedirect) StatusCode() int
type StatusSeeOther ¶
type StatusSeeOther struct {
// contains filtered or unexported fields
}
Example ¶
m := RedirectWithStatusSeeOther(&(net_url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) fmt.Println(m.Error())
Output: 303 /test Location: /test
func RedirectWithStatusSeeOther ¶
func RedirectWithStatusSeeOther(u *net_url.URL) *StatusSeeOther
func (StatusSeeOther) StatusCode ¶
func (StatusSeeOther) StatusCode() int
type StatusTemporaryRedirect ¶
type StatusTemporaryRedirect struct {
// contains filtered or unexported fields
}
Example ¶
m := RedirectWithStatusTemporaryRedirect(&(net_url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) fmt.Println(m.Error())
Output: 307 /test Location: /test
func RedirectWithStatusTemporaryRedirect ¶
func RedirectWithStatusTemporaryRedirect(u *net_url.URL) *StatusTemporaryRedirect
func (StatusTemporaryRedirect) Error ¶
func (r StatusTemporaryRedirect) Error() string
Redirect could be an error
func (StatusTemporaryRedirect) StatusCode ¶
func (StatusTemporaryRedirect) StatusCode() int
type StatusUseProxy ¶
type StatusUseProxy struct {
// contains filtered or unexported fields
}
Example ¶
m := RedirectWithStatusUseProxy(&(net_url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) fmt.Println(m.Error())
Output: 305 /test Location: /test
func RedirectWithStatusUseProxy ¶
func RedirectWithStatusUseProxy(u *net_url.URL) *StatusUseProxy
func (StatusUseProxy) StatusCode ¶
func (StatusUseProxy) StatusCode() int
type Upgrader ¶ added in v1.4.0
type Upgrader interface {
Upgrade(w http.ResponseWriter, r *http.Request) error
}
type VideoOgg ¶
Example ¶
m := NewVideoOgg() fmt.Println(m.ContentType())
Output: video/ogg
func NewVideoOgg ¶
func NewVideoOgg() *VideoOgg
func (VideoOgg) ContentType ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.