Documentation ¶
Index ¶
- Constants
- func ClientIP(r *http.Request) string
- func ClientIPByHeaderForwardedFor(headerForwardedFor string) string
- func ClientIPByHeaderRealIP(headerRealIP string) string
- func ContextWithStatusCode(ctx context.Context, code int) context.Context
- func MaybeWriteHeader(ctx context.Context, w io.Writer, ct string, param map[string]string)
- func Metadata(k string, vs ...string) kit.Metadata
- func StatusCodeFromContext(ctx context.Context) int
- type ApplicationOgg
- type Attachment
- type AudioMidi
- type AudioMp3
- type AudioOgg
- type AudioWave
- type AudioWebm
- type CSS
- type Encode
- type HTML
- type ImageBmp
- type ImageGIF
- type ImageJPEG
- type ImagePNG
- type ImageSVG
- type ImageWebp
- type Method
- type MethodConnect
- type MethodDelete
- type MethodGet
- type MethodHead
- type MethodOptions
- type MethodPatch
- type MethodPost
- type MethodPut
- type MethodTrace
- type Plain
- type RedirectDescriber
- type RequestInfo
- type ResolveEncode
- type Response
- type ResponseWrapper
- func Compose(rws ...ResponseWrapper) ResponseWrapper
- func WrapContentType(ct string) ResponseWrapper
- func WrapCookies(cookies ...*http.Cookie) ResponseWrapper
- func WrapMeta(metas ...kit.Metadata) ResponseWrapper
- func WrapSchema(s interface{}) ResponseWrapper
- func WrapStatusCode(statusCode int) ResponseWrapper
- type ResponseWriteError
- type StatusFound
- type StatusMovedPermanently
- type StatusMultipleChoices
- type StatusNotModified
- type StatusPermanentRedirect
- type StatusSeeOther
- type StatusTemporaryRedirect
- type StatusUseProxy
- type Upgrader
- type VideoOgg
- type VideoWebm
- type WithContentType
- type WithCookies
- type WithFromRequestInfo
- type WithHeader
- type WithStatusCode
Examples ¶
- ApplicationOgg
- AudioMidi
- AudioMp3
- AudioOgg
- AudioWave
- AudioWebm
- CSS
- HTML
- ImageBmp
- ImageGIF
- ImageJPEG
- ImagePNG
- ImageSVG
- ImageWebp
- 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" MIME_PLAIN_TEXT = "text/plain" )
Variables ¶
This section is empty.
Functions ¶
func ClientIPByHeaderForwardedFor ¶
ClientIPByHeaderForwardedFor X-Forwarded-For: client, proxy1, proxy2 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
func ClientIPByHeaderRealIP ¶
ClientIPByHeaderRealIP X-Forwarded-For: client, proxy1, proxy2 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
func ContextWithStatusCode ¶
func MaybeWriteHeader ¶
func StatusCodeFromContext ¶
Types ¶
type ApplicationOgg ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.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
func (*Attachment) ContentType ¶
func (a *Attachment) ContentType() string
func (*Attachment) Meta ¶
func (a *Attachment) Meta() kit.Metadata
type AudioMidi ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewAudioMidi() fmt.Println(m.ContentType()) }
Output: audio/midi
func NewAudioMidi ¶
func NewAudioMidi() *AudioMidi
func (AudioMidi) ContentType ¶
type AudioMp3 ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewAudioMp3() fmt.Println(m.ContentType()) }
Output: audio/mpeg
func NewAudioMp3 ¶
func NewAudioMp3() *AudioMp3
func (AudioMp3) ContentType ¶
type AudioOgg ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewAudioOgg() fmt.Println(m.ContentType()) }
Output: audio/ogg
func NewAudioOgg ¶
func NewAudioOgg() *AudioOgg
func (AudioOgg) ContentType ¶
type AudioWave ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewAudioWave() fmt.Println(m.ContentType()) }
Output: audio/wav
func NewAudioWave ¶
func NewAudioWave() *AudioWave
func (AudioWave) ContentType ¶
type AudioWebm ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewAudioWebm() fmt.Println(m.ContentType()) }
Output: audio/webm
func NewAudioWebm ¶
func NewAudioWebm() *AudioWebm
func (AudioWebm) ContentType ¶
type CSS ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewCSS() fmt.Println(m.ContentType()) }
Output: text/css
func (CSS) ContentType ¶
type HTML ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewHTML() fmt.Println(m.ContentType()) }
Output: text/html
func (HTML) ContentType ¶
type ImageBmp ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewImageBmp() fmt.Println(m.ContentType()) }
Output: image/bmp
func NewImageBmp ¶
func NewImageBmp() *ImageBmp
func (ImageBmp) ContentType ¶
type ImageGIF ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewImageGIF() fmt.Println(m.ContentType()) }
Output: image/gif
func NewImageGIF ¶
func NewImageGIF() *ImageGIF
func (ImageGIF) ContentType ¶
type ImageJPEG ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewImageJPEG() fmt.Println(m.ContentType()) }
Output: image/jpeg
func NewImageJPEG ¶
func NewImageJPEG() *ImageJPEG
func (ImageJPEG) ContentType ¶
type ImagePNG ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewImagePNG() fmt.Println(m.ContentType()) }
Output: image/png
func NewImagePNG ¶
func NewImagePNG() *ImagePNG
func (ImagePNG) ContentType ¶
type ImageSVG ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewImageSVG() fmt.Println(m.ContentType()) }
Output: image/svg+xml
func NewImageSVG ¶
func NewImageSVG() *ImageSVG
func (ImageSVG) ContentType ¶
type ImageWebp ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewImageWebp() fmt.Println(m.ContentType()) }
Output: image/webp
func NewImageWebp ¶
func NewImageWebp() *ImageWebp
func (ImageWebp) ContentType ¶
type MethodConnect ¶
type MethodConnect struct{}
func (MethodConnect) Method ¶
func (MethodConnect) Method() string
type MethodDelete ¶
type MethodDelete struct{}
func (MethodDelete) Method ¶
func (MethodDelete) Method() string
type MethodHead ¶
type MethodHead struct{}
func (MethodHead) Method ¶
func (MethodHead) Method() string
type MethodOptions ¶
type MethodOptions struct{}
func (MethodOptions) Method ¶
func (MethodOptions) Method() string
type MethodPatch ¶
type MethodPatch struct{}
func (MethodPatch) Method ¶
func (MethodPatch) Method() string
type MethodPost ¶
type MethodPost struct{}
func (MethodPost) Method ¶
func (MethodPost) Method() string
type MethodTrace ¶
type MethodTrace struct{}
func (MethodTrace) Method ¶
func (MethodTrace) Method() string
type Plain ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewPlain() fmt.Println(m.ContentType()) }
Output: text/plain
func (Plain) ContentType ¶
type RedirectDescriber ¶
type RedirectDescriber interface { WithStatusCode Location() *url.URL }
type RequestInfo ¶
type RequestInfo interface { Context() context.Context Values(in string, name string) []string Header() http.Header Body() io.ReadCloser }
func NewRequestInfo ¶
func NewRequestInfo(r *http.Request) RequestInfo
type ResolveEncode ¶
type Response ¶
type Response struct { Value interface{} // Value of body Meta kit.Metadata Cookies []*http.Cookie Location *url.URL ContentType string StatusCode int }
func ResponseFrom ¶
func ResponseFrom(v interface{}) *Response
func (*Response) WriteTo ¶
func (r *Response) WriteTo(rw http.ResponseWriter, req *http.Request, resolve ResolveEncode) error
type ResponseWrapper ¶
type ResponseWrapper func(v interface{}) *Response
func Compose ¶
func Compose(rws ...ResponseWrapper) ResponseWrapper
func WrapContentType ¶
func WrapContentType(ct string) ResponseWrapper
func WrapCookies ¶
func WrapCookies(cookies ...*http.Cookie) ResponseWrapper
func WrapMeta ¶
func WrapMeta(metas ...kit.Metadata) ResponseWrapper
func WrapSchema ¶
func WrapSchema(s interface{}) ResponseWrapper
func WrapStatusCode ¶
func WrapStatusCode(statusCode int) ResponseWrapper
type ResponseWriteError ¶
type StatusFound ¶
type StatusFound struct{ *Response }
Example ¶
package main import ( "fmt" "net/url" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.RedirectWithStatusFound(&(url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) }
Output: 302 /test
func RedirectWithStatusFound ¶
func RedirectWithStatusFound(u *url.URL) *StatusFound
func (StatusFound) Location ¶
func (r StatusFound) Location() *url.URL
func (StatusFound) StatusCode ¶
func (StatusFound) StatusCode() int
type StatusMovedPermanently ¶
type StatusMovedPermanently struct{ *Response }
Example ¶
package main import ( "fmt" "net/url" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.RedirectWithStatusMovedPermanently(&(url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) }
Output: 301 /test
func RedirectWithStatusMovedPermanently ¶
func RedirectWithStatusMovedPermanently(u *url.URL) *StatusMovedPermanently
func (StatusMovedPermanently) Location ¶
func (r StatusMovedPermanently) Location() *url.URL
func (StatusMovedPermanently) StatusCode ¶
func (StatusMovedPermanently) StatusCode() int
type StatusMultipleChoices ¶
type StatusMultipleChoices struct{ *Response }
Example ¶
package main import ( "fmt" "net/url" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.RedirectWithStatusMultipleChoices(&(url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) }
Output: 300 /test
func RedirectWithStatusMultipleChoices ¶
func RedirectWithStatusMultipleChoices(u *url.URL) *StatusMultipleChoices
func (StatusMultipleChoices) Location ¶
func (r StatusMultipleChoices) Location() *url.URL
func (StatusMultipleChoices) StatusCode ¶
func (StatusMultipleChoices) StatusCode() int
type StatusNotModified ¶
type StatusNotModified struct{ *Response }
Example ¶
package main import ( "fmt" "net/url" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.RedirectWithStatusNotModified(&(url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) }
Output: 304 /test
func RedirectWithStatusNotModified ¶
func RedirectWithStatusNotModified(u *url.URL) *StatusNotModified
func (StatusNotModified) Location ¶
func (r StatusNotModified) Location() *url.URL
func (StatusNotModified) StatusCode ¶
func (StatusNotModified) StatusCode() int
type StatusPermanentRedirect ¶
type StatusPermanentRedirect struct{ *Response }
Example ¶
package main import ( "fmt" "net/url" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.RedirectWithStatusPermanentRedirect(&(url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) }
Output: 308 /test
func RedirectWithStatusPermanentRedirect ¶
func RedirectWithStatusPermanentRedirect(u *url.URL) *StatusPermanentRedirect
func (StatusPermanentRedirect) Location ¶
func (r StatusPermanentRedirect) Location() *url.URL
func (StatusPermanentRedirect) StatusCode ¶
func (StatusPermanentRedirect) StatusCode() int
type StatusSeeOther ¶
type StatusSeeOther struct{ *Response }
Example ¶
package main import ( "fmt" "net/url" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.RedirectWithStatusSeeOther(&(url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) }
Output: 303 /test
func RedirectWithStatusSeeOther ¶
func RedirectWithStatusSeeOther(u *url.URL) *StatusSeeOther
func (StatusSeeOther) Location ¶
func (r StatusSeeOther) Location() *url.URL
func (StatusSeeOther) StatusCode ¶
func (StatusSeeOther) StatusCode() int
type StatusTemporaryRedirect ¶
type StatusTemporaryRedirect struct{ *Response }
Example ¶
package main import ( "fmt" "net/url" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.RedirectWithStatusTemporaryRedirect(&(url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) }
Output: 307 /test
func RedirectWithStatusTemporaryRedirect ¶
func RedirectWithStatusTemporaryRedirect(u *url.URL) *StatusTemporaryRedirect
func (StatusTemporaryRedirect) Location ¶
func (r StatusTemporaryRedirect) Location() *url.URL
func (StatusTemporaryRedirect) StatusCode ¶
func (StatusTemporaryRedirect) StatusCode() int
type StatusUseProxy ¶
type StatusUseProxy struct{ *Response }
Example ¶
package main import ( "fmt" "net/url" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.RedirectWithStatusUseProxy(&(url.URL{ Path: "/test", })) fmt.Println(m.StatusCode()) fmt.Println(m.Location()) }
Output: 305 /test
func RedirectWithStatusUseProxy ¶
func RedirectWithStatusUseProxy(u *url.URL) *StatusUseProxy
func (StatusUseProxy) Location ¶
func (r StatusUseProxy) Location() *url.URL
func (StatusUseProxy) StatusCode ¶
func (StatusUseProxy) StatusCode() int
type VideoOgg ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewVideoOgg() fmt.Println(m.ContentType()) }
Output: video/ogg
func NewVideoOgg ¶
func NewVideoOgg() *VideoOgg
func (VideoOgg) ContentType ¶
type VideoWebm ¶
Example ¶
package main import ( "fmt" "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" ) func main() { m := httpx.NewVideoWebm() fmt.Println(m.ContentType()) }
Output: video/webm
func NewVideoWebm ¶
func NewVideoWebm() *VideoWebm
func (VideoWebm) ContentType ¶
type WithContentType ¶
type WithContentType interface {
ContentType() string
}
type WithCookies ¶
type WithFromRequestInfo ¶
type WithFromRequestInfo interface {
FromRequestInfo(ri RequestInfo) error
}
type WithHeader ¶
type WithStatusCode ¶
type WithStatusCode interface {
StatusCode() int
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.