http

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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 struct {
	// contains filtered or unexported fields
}

func NewCookie added in v0.1.14

func NewCookie() Cookie

func (*Cookie) Expires added in v0.1.14

func (k *Cookie) Expires(time time.Time) *Cookie

func (*Cookie) HttpOnly added in v0.1.14

func (k *Cookie) HttpOnly(httpOnly bool) *Cookie

func (*Cookie) MaxAge added in v0.1.14

func (k *Cookie) MaxAge(maxAge int) *Cookie

func (*Cookie) Name added in v0.1.14

func (k *Cookie) Name(name string) *Cookie

func (*Cookie) Path added in v0.1.15

func (k *Cookie) Path(path string) *Cookie

func (*Cookie) Raw added in v0.1.14

func (k *Cookie) Raw(raw string) *Cookie

func (*Cookie) RawExpires added in v0.1.14

func (k *Cookie) RawExpires() string

func (*Cookie) SameSite added in v0.1.14

func (k *Cookie) SameSite(sameSite http.SameSite) *Cookie

func (*Cookie) Secure added in v0.1.14

func (k *Cookie) Secure(secure bool) *Cookie

func (*Cookie) Unparsed added in v0.1.14

func (k *Cookie) Unparsed() []string

func (*Cookie) Value added in v0.1.14

func (k *Cookie) Value(value string) *Cookie

type ErrMiddleware

type ErrMiddleware struct {
	Error error
	Code  int
}

type HttpResponse

type HttpResponse struct {
	// contains filtered or unexported fields
}

func (*HttpResponse) Append

func (h *HttpResponse) Append(field string, value string) Response

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 (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) Set

func (h *HttpResponse) Set(field string, value string) Response

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) Write

func (h *HttpResponse) Write(data []byte) (int, error)

func (*HttpResponse) WriteHeader

func (h *HttpResponse) WriteHeader(statusCode int)

type Middleware

type Middleware func(Request, Response, Next)

type Next

type Next func(Request, Response)

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 NewRequest(r *http.Request) *Request

func (*Request) AddCookie

func (h *Request) AddCookie(c *http.Cookie)

func (*Request) BasicAuth

func (h *Request) BasicAuth() (username string, password string, ok bool)

func (*Request) Clone

func (h *Request) Clone(ctx context.Context) *http.Request

func (*Request) Context

func (h *Request) Context() context.Context

func (*Request) Cookie

func (h *Request) Cookie(name string) (Cookie, error)

func (*Request) Cookies

func (h *Request) Cookies() []*http.Cookie

func (*Request) ErrorMiddleware

func (h *Request) ErrorMiddleware(e error, code int) Request

func (*Request) FormFile

func (h *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, error)

func (*Request) FormValue

func (h *Request) FormValue(key string) string

func (*Request) MultipartReader

func (h *Request) MultipartReader() (*multipart.Reader, error)

func (*Request) ParseForm

func (h *Request) ParseForm() error

func (*Request) ParseMultipartForm

func (h *Request) ParseMultipartForm(maxMemory int64) error

func (*Request) ProtoAtLeast

func (h *Request) ProtoAtLeast(major int, minor int) bool

func (*Request) Referer

func (h *Request) Referer() string

func (*Request) UserAgent

func (h *Request) UserAgent() string

func (*Request) WithContext

func (h *Request) WithContext(ctx context.Context) Request

func (*Request) Write

func (h *Request) Write(w io.Writer) error

func (*Request) WriteProxy

func (h *Request) WriteProxy(w io.Writer) error

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

type RouterKey

type RouterKey string

Jump to

Keyboard shortcuts

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