http

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	context.Context
	WithValue(key string, value any)
	Request() Request
	Response() Response
	EngineContext() any
	Header(key, defaultValue string) string
	Headers() http.Header
	Method() string
	Path() string
	Secure() bool
	Url() string
	FullUrl() string
	Ip() string

	//Input Retrieve  an input item from the request: /users/{id}
	Params(key string) string
	// Query Retrieve a query string item form the request: /users?id=1
	Query(key, defaultValue string) string
	// Form Retrieve a form string item form the post: /users POST:id=1
	Form(key, defaultValue string) string
	Bind(obj any) error
	File(name string) (File, error)

	AbortWithStatus(code int)
	Next() error

	Cookies(key string, defaultValue ...string) string
	Cookie(co *Cookie)
}
type Cookie struct {
	Name        string    `json:"name"`
	Value       string    `json:"value"`
	Path        string    `json:"path"`
	Domain      string    `json:"domain"`
	MaxAge      int       `json:"max_age"`
	Expires     time.Time `json:"expires"`
	Secure      bool      `json:"secure"`
	HTTPOnly    bool      `json:"http_only"`
	SameSite    string    `json:"same_site"`
	SessionOnly bool      `json:"session_only"`
}

type ErrorHandler added in v1.0.3

type ErrorHandler = func(Context, error) error

type File

type File interface {
	Store(dst string) error
	File() *multipart.FileHeader
}

type FormRequest

type FormRequest interface {
	Messages() map[string]string
	Authorize() bool
}

type HandlerFunc

type HandlerFunc func(Context) error

func (*HandlerFunc) ServeHTTP added in v1.0.5

func (h *HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Json

type Json map[string]any

type Request

type Request interface {
	Origin() *http.Request
	Response() Response
}

type Response

type Response interface {
	String(code int, format string, values ...any) error
	Json(code int, obj any) error
	File(filepath string, compress ...bool) error
	Download(filepath, filename string) error
	Success() ResponseSuccess
	StatusCode() int
	Header(key, value string) Response
	Vary(key string, value ...string)
}

type ResponseSuccess

type ResponseSuccess interface {
	String(format string, values ...any) error
	Json(obj any) error
}

Jump to

Keyboard shortcuts

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