Documentation
¶
Index ¶
- Constants
- func MiddlewareErrorCtx(ctx context.Context, e ErrMiddleware) context.Context
- type Cookie
- func (k *Cookie) Expires(time time.Time) *Cookie
- func (k *Cookie) HttpOnly(httpOnly bool) *Cookie
- func (k *Cookie) MaxAge(maxAge int) *Cookie
- func (k *Cookie) Name(name string) *Cookie
- func (k *Cookie) Path(path string) *Cookie
- func (k *Cookie) Raw(raw string) *Cookie
- func (k *Cookie) RawExpires() string
- func (k *Cookie) SameSite(sameSite http.SameSite) *Cookie
- func (k *Cookie) Secure(secure bool) *Cookie
- func (k *Cookie) Unparsed() []string
- func (k *Cookie) Value(value string) *Cookie
- type ErrMiddleware
- type HttpResponse
- func (h *HttpResponse) Append(field string, value string) Response
- func (h *HttpResponse) Attachment() Response
- func (h *HttpResponse) ClearCookie(cookie Cookie) Response
- func (h *HttpResponse) Cookie(cookie Cookie) Response
- func (h *HttpResponse) Download()
- func (h *HttpResponse) End()
- func (h *HttpResponse) Format() Response
- func (h *HttpResponse) Get() Response
- func (h *HttpResponse) Header() http.Header
- func (h *HttpResponse) Json(data interface{})
- func (h *HttpResponse) Jsonp()
- func (h *HttpResponse) Links() Response
- func (h *HttpResponse) Location(path string) Response
- func (h *HttpResponse) Redirect(url string, code int)
- func (h *HttpResponse) Send(data interface{})
- func (h *HttpResponse) SendFile()
- func (h *HttpResponse) SendStatus()
- func (h *HttpResponse) Set(field string, value string) Response
- func (h *HttpResponse) Status(code int) Response
- func (h *HttpResponse) Type(httpType string) Response
- func (h *HttpResponse) Vary() Response
- func (h *HttpResponse) Write(data []byte) (int, error)
- func (h *HttpResponse) WriteHeader(statusCode int)
- type Middleware
- type Next
- type Request
- func (h *Request) AddCookie(c *http.Cookie)
- func (h *Request) BasicAuth() (username string, password string, ok bool)
- func (h *Request) Clone(ctx context.Context) *http.Request
- func (h *Request) Context() context.Context
- func (h *Request) Cookie(name string) (Cookie, error)
- func (h *Request) Cookies() []*http.Cookie
- func (h *Request) ErrorMiddleware(e error, code int) Request
- func (h *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (h *Request) FormValue(key string) string
- func (h *Request) MultipartReader() (*multipart.Reader, error)
- func (h *Request) ParseForm() error
- func (h *Request) ParseMultipartForm(maxMemory int64) error
- func (h *Request) ProtoAtLeast(major int, minor int) bool
- func (h *Request) Referer() string
- func (h *Request) UserAgent() string
- func (h *Request) WithContext(ctx context.Context) Request
- func (h *Request) Write(w io.Writer) error
- func (h *Request) WriteProxy(w io.Writer) error
- type Response
- type RouterKey
Constants ¶
View Source
const ( HeaderContentType = "Content-Type" MimeApplicationJson = "application/json" )
View Source
const (
ErrMiddlewareKey = RouterKey("error")
)
Variables ¶
This section is empty.
Functions ¶
func MiddlewareErrorCtx ¶
func MiddlewareErrorCtx(ctx context.Context, e ErrMiddleware) context.Context
Types ¶
type Cookie ¶ added in v0.1.14
type Cookie struct {
// contains filtered or unexported fields
}
func (*Cookie) RawExpires ¶ added in v0.1.14
type ErrMiddleware ¶
type HttpResponse ¶
type HttpResponse struct {
// contains filtered or unexported fields
}
func (*HttpResponse) Attachment ¶
func (h *HttpResponse) Attachment() Response
func (*HttpResponse) ClearCookie ¶
func (h *HttpResponse) ClearCookie(cookie Cookie) Response
func (*HttpResponse) Cookie ¶
func (h *HttpResponse) Cookie(cookie Cookie) Response
func (*HttpResponse) Download ¶
func (h *HttpResponse) Download()
func (*HttpResponse) End ¶
func (h *HttpResponse) End()
func (*HttpResponse) Format ¶
func (h *HttpResponse) Format() Response
func (*HttpResponse) Get ¶
func (h *HttpResponse) Get() Response
func (*HttpResponse) Header ¶
func (h *HttpResponse) Header() http.Header
func (*HttpResponse) Json ¶
func (h *HttpResponse) Json(data interface{})
func (*HttpResponse) Jsonp ¶
func (h *HttpResponse) Jsonp()
func (*HttpResponse) Links ¶
func (h *HttpResponse) Links() Response
func (*HttpResponse) Location ¶
func (h *HttpResponse) Location(path string) Response
func (*HttpResponse) Redirect ¶
func (h *HttpResponse) Redirect(url string, code int)
func (*HttpResponse) Send ¶
func (h *HttpResponse) Send(data interface{})
func (*HttpResponse) SendFile ¶
func (h *HttpResponse) SendFile()
func (*HttpResponse) SendStatus ¶
func (h *HttpResponse) SendStatus()
func (*HttpResponse) Status ¶
func (h *HttpResponse) Status(code int) Response
func (*HttpResponse) Type ¶
func (h *HttpResponse) Type(httpType string) Response
func (*HttpResponse) Vary ¶
func (h *HttpResponse) Vary() Response
func (*HttpResponse) WriteHeader ¶
func (h *HttpResponse) WriteHeader(statusCode int)
type Middleware ¶
type Request ¶
type Request struct {
Method string
URL *url.URL
Proto string
ProtoMajor int
ProtoMinor int
Header http.Header
Body io.ReadCloser
GetBody func() (io.ReadCloser, error)
ContentLength int64
TransferEncoding []string
Close bool
Host string
Form url.Values
PostForm url.Values
MultipartForm *multipart.Form
Trailer http.Header
RemoteAddr string
RequestURI string
TLS *tls.ConnectionState
Cancel <-chan struct{}
Response *http.Response
// contains filtered or unexported fields
}
func NewRequest ¶
func (*Request) ParseMultipartForm ¶
type Response ¶
type Response interface {
// Get header
Header() http.Header
// Write writes the data to the connection as part of an HTTP reply.
Write([]byte) (int, error)
// WriteHeader sends an HTTP response header with the provided status code.
WriteHeader(statusCode int)
// Sets the response’s HTTP header field to value
Set(string, string) Response
// Sets the HTTP status for the response
Status(int) Response
// Sets the Content-Type HTTP header to the MIME type as determined by the specified type.
Type(string) Response
// Sends a JSON response.
Json(data interface{})
// Sends the HTTP response.
Send(data interface{})
// Sets a created cookie.
Cookie(Cookie) Response
// Clears the cookie specified by name.
ClearCookie(cookie Cookie) Response
// Redirects to the URL derived from the specified path, with specified status.
Redirect(path string, code int)
// Sets the response Location HTTP header to the specified path parameter.
Location(path string) Response
// Appends the specified value to the HTTP response header field.
Append(key string, val string) Response
}
func NewResponse ¶
func NewResponse(w http.ResponseWriter, r *http.Request) Response
Click to show internal directories.
Click to hide internal directories.