contracts

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: BSD-3-Clause Imports: 6 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileServer

type FileServer interface {
	Path() string
	Prefix() string
}

type HTMLer added in v0.0.8

type HTMLer interface {
	HTML() []byte
}

type InputSource

type InputSource interface {
	Get(key string) []byte
	ParamBytes(key string) []byte
	File(key string) (UploadFile, error)
	GetValue(key ...string) InputValue
}

InputSource is general input source

type InputValue

type InputValue []byte

func (InputValue) Each

func (i InputValue) Each(h JsonHandler) error

func (InputValue) GetBool

func (i InputValue) GetBool() (bool, error)

func (InputValue) GetFloat

func (i InputValue) GetFloat() (float64, error)

func (InputValue) GetInt

func (i InputValue) GetInt() (int64, error)

func (InputValue) GetString

func (i InputValue) GetString() string

func (InputValue) GetUInt

func (i InputValue) GetUInt() (uint64, error)

func (InputValue) GetValue

func (i InputValue) GetValue(key string) (InputValue, jsonparser.ValueType, error)

func (InputValue) Unmarshal

func (i InputValue) Unmarshal(v interface{}) error

type JsonHandler

type JsonHandler func(value InputValue, dataType jsonparser.ValueType)

type RequestContract

type RequestContract interface {
	InputSource
	Context() context.Context
	Params() map[string][]byte
	Param(key string) string
	ParamInt64(key string) (int64, error)
	ParamUint64(key string) (uint64, error)
	ParamInt(key string) (int, error)
	SetParams(params map[string][]byte)
	SetParamsSlice(paramsSlice [][]byte)
	ParamsSlice() [][]byte
	Accepts() []byte
	ExceptsJson() bool
	RequestWithJson() bool
	IsXmlHttpRequest() bool
	GetMethod() string
	GetPathBytes() []byte
	GetUri() []byte
	GetInt64(key string) (int64, error)
	GetUint64(key string) (uint64, error)
	GetString(key string) string
	GetInt(key string) (int, error)
	GetClientIp() string
	GetContent() []byte
	Unmarshal(to interface{}) error
	GetSignature() []byte
	Header(key string) []byte
	HeaderString(key string) string
	SetHeader(key string, value []byte) RequestContract
	SetHeaderString(key, value string) RequestContract
	Authorization() []byte
	BearerToken() ([]byte, error)
	ToString() string
}

RequestContract is interface of http request

type ResponseContract

type ResponseContract interface {
	Content() []byte
	Headers() map[string]string
	SetHeader(key string, value string) ResponseContract
	SetHeaders(headers map[string]string) ResponseContract
	StatusCode() int
	SetStatusCode(code int) ResponseContract
	Handled() bool
}

type TemplateResponseContract

type TemplateResponseContract interface {
	Template() *template.Template
	TemplateData() interface{}
}

type UploadFile

type UploadFile interface {
	Save(dist string) error
	Open() (multipart.File, error)
	Close() error
	Filename() string
}

type WithContentType added in v0.0.8

type WithContentType interface {
	ContentType() string
}

type WithHeaders

type WithHeaders interface {
	Headers() map[string]string
}

type WithStatusCode

type WithStatusCode interface {
	StatusCode() int
}

Jump to

Keyboard shortcuts

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