context

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultHeader = func() map[string]string {
		return map[string]string{}
	}
	TextHeader = func() map[string]string {
		return map[string]string{
			"Content-Type": "text/html; charset=utf-8",
		}
	}
	JsonHeader = func() map[string]string {
		return map[string]string{
			"Content-Type": "application/json; charset=utf-8",
		}
	}
	HtmlHeader = func() map[string]string {
		return map[string]string{
			"Content-Type": "text/html; charset=utf-8",
		}
	}
)

Functions

func HtmlErrorResponseFormatter

func HtmlErrorResponseFormatter(err exception.Exception, code int, debug bool, headers map[string]string) contract.ResponseContract

func JsonErrorResponseFormatter

func JsonErrorResponseFormatter(err exception.Exception, code int, debug bool, headers map[string]string) contract.ResponseContract

func JsonResponse

func JsonResponse(data interface{}, code int, headers map[string]string) contract.ResponseContract

Types

type ErrorResponse

type ErrorResponse struct {
	*Response
	// contains filtered or unexported fields
}

func ErrResponse

func ErrResponse(e exception.Exception, code int, headers map[string]string) *ErrorResponse

func ErrResponseFromError

func ErrResponseFromError(e error, code int, headers map[string]string) *ErrorResponse

func ErrResponseFromOrigin

func ErrResponseFromOrigin(resp *Response) *ErrorResponse

func HttpErrorResponse

func HttpErrorResponse(message string, statusCode int, code int, headers map[string]string) *ErrorResponse

func NotFoundResponse

func NotFoundResponse(message string) *ErrorResponse

func (*ErrorResponse) E

type ErrorResponseFormatter

type ErrorResponseFormatter func(err exception.Exception, code int, debug bool, headers map[string]string) contract.ResponseContract

type File

type File struct {
	*Response
	// contains filtered or unexported fields
}

func (*File) Path

func (f *File) Path() string

type Request

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

func NewRequest

func NewRequest(origin *fasthttp.RequestCtx) *Request

func (*Request) Accepts

func (r *Request) Accepts() []byte

func (*Request) Authorization

func (r *Request) Authorization() []byte

func (*Request) BearerToken

func (r *Request) BearerToken() ([]byte, error)

func (*Request) ExceptsJson

func (r *Request) ExceptsJson() bool

func (*Request) Get

func (r *Request) Get(key string) []byte

func (*Request) GetClientIp

func (r *Request) GetClientIp() string

func (*Request) GetContent

func (r *Request) GetContent() []byte

func (*Request) GetInt

func (r *Request) GetInt(key string) (int, error)

func (*Request) GetInt64

func (r *Request) GetInt64(key string) (int64, error)

func (*Request) GetMethod

func (r *Request) GetMethod() string

func (*Request) GetPathBytes

func (r *Request) GetPathBytes() []byte

func (*Request) GetSignature

func (r *Request) GetSignature() []byte

func (*Request) GetString

func (r *Request) GetString(key string) string

func (*Request) GetUint64

func (r *Request) GetUint64(key string) (uint64, error)

func (*Request) Header

func (r *Request) Header(key string) []byte

func (*Request) HeaderString

func (r *Request) HeaderString(key string) string

func (*Request) IsXmlHttpRequest

func (r *Request) IsXmlHttpRequest() bool

func (*Request) Origin

func (r *Request) Origin() *fasthttp.RequestCtx

func (*Request) Param

func (r *Request) Param(key string) string

func (*Request) ParamInt

func (r *Request) ParamInt(key string) (int, error)

func (*Request) ParamInt64

func (r *Request) ParamInt64(key string) (int64, error)

func (*Request) ParamUint64

func (r *Request) ParamUint64(key string) (uint64, error)

func (*Request) Params

func (r *Request) Params() map[string]string

func (*Request) SetHeader

func (r *Request) SetHeader(key string, value []byte) contract.RequestContract

func (*Request) SetHeaderString

func (r *Request) SetHeaderString(key, value string) contract.RequestContract

func (*Request) SetParams

func (r *Request) SetParams(params map[string]string)

func (*Request) SetUser

func (r *Request) SetUser(u contracts.User)

func (*Request) Unmarshal

func (r *Request) Unmarshal(to interface{}) error

func (*Request) User

func (r *Request) User() contracts.User

type Response

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

Response http response

func HtmlResponse

func HtmlResponse(content string, code int) *Response

func NewResponse

func NewResponse(content []byte, headers map[string]string, code int) *Response

func TextResponse

func TextResponse(content string, code int) *Response

func (*Response) Content

func (r *Response) Content() []byte

Content response body

func (*Response) Headers

func (r *Response) Headers() map[string]string

Headers response headers

func (*Response) SetHeader

func (r *Response) SetHeader(key string, value string) contract.ResponseContract

func (*Response) SetStatusCode

func (r *Response) SetStatusCode(code int)

func (*Response) StatusCode

func (r *Response) StatusCode() int

StatusCode status code

type TemplateResponse

type TemplateResponse struct {
	*Response
	// contains filtered or unexported fields
}

func TempResponse

func TempResponse(t *template.Template, code int, data interface{}) *TemplateResponse

func (*TemplateResponse) SetTemplateData

func (t *TemplateResponse) SetTemplateData(templateData interface{}) *TemplateResponse

func (*TemplateResponse) Template

func (t *TemplateResponse) Template() *template.Template

func (*TemplateResponse) TemplateData

func (t *TemplateResponse) TemplateData() interface{}

Jump to

Keyboard shortcuts

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