base

package
v0.0.0-...-869b963 Latest Latest
Warning

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

Go to latest
Published: May 11, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadData

func ReadData(r io.Reader, d interface{}) error

func UUID

func UUID() string

func WriteData

func WriteData(w io.Writer, d interface{}) error

Types

type BaseHandler

type BaseHandler struct{}

func (*BaseHandler) ReadData

func (this *BaseHandler) ReadData(r io.Reader, d interface{}) error

func (*BaseHandler) ServeHTTP

func (this *BaseHandler) ServeHTTP(rsp http.ResponseWriter, req *http.Request)

func (*BaseHandler) Write

func (this *BaseHandler) Write(w io.Writer, data []byte) (int, error)

func (*BaseHandler) WriteData

func (this *BaseHandler) WriteData(w io.Writer, d interface{}) error

type BasicHandler

type BasicHandler struct {
	BaseHandler
	// contains filtered or unexported fields
}

func (*BasicHandler) HandlerInit

func (this *BasicHandler) HandlerInit(h Handler)

func (*BasicHandler) ProcessAdd

func (this *BasicHandler) ProcessAdd(context *HttpContext) error

func (*BasicHandler) ProcessDelete

func (this *BasicHandler) ProcessDelete(context *HttpContext) error

func (*BasicHandler) ProcessExtend

func (this *BasicHandler) ProcessExtend(context *HttpContext) error

func (*BasicHandler) ProcessModify

func (this *BasicHandler) ProcessModify(context *HttpContext) error

func (*BasicHandler) ProcessRequest

func (this *BasicHandler) ProcessRequest(context *HttpContext) error

func (*BasicHandler) ProcessResponse

func (this *BasicHandler) ProcessResponse(context *HttpContext) error

func (*BasicHandler) ProcessUpdate

func (this *BasicHandler) ProcessUpdate(context *HttpContext) error

func (*BasicHandler) ServeHTTP

func (this *BasicHandler) ServeHTTP(
	rsp http.ResponseWriter, req *http.Request)

type CommandRequest

type CommandRequest struct {
	Id   string          `json:"id"`
	Cmd  string          `json:"command"`
	Data json.RawMessage `json:"data,omitempty"`
}

type CommandResponse

type CommandResponse struct {
	Id   string      `json:"id"`
	Msg  string      `json:"msg"`
	Code int         `json:"code"`
	Data interface{} `json:"data,omitempty"`
}

type Handler

type Handler interface {
	HandlerInit(h Handler)
	ProcessAdd(context *HttpContext) error
	ProcessModify(context *HttpContext) error
	ProcessUpdate(context *HttpContext) error
	ProcessDelete(context *HttpContext) error
	ProcessExtend(context *HttpContext) error
	ProcessRequest(context *HttpContext) error
	ProcessResponse(context *HttpContext) error
}

type HttpContext

type HttpContext struct {
	HttpReq *http.Request
	HttpRsp http.ResponseWriter

	ReqData *CommandRequest
	RspData *CommandResponse
}

func MakeFailure

func MakeFailure(
	context *HttpContext, err error) *HttpContext

func MakeFailure2

func MakeFailure2(
	context *HttpContext, code int, err error) *HttpContext

func MakeFailureResponse

func MakeFailureResponse(context *HttpContext,
	code int, err error, data interface{}) *HttpContext

func MakeSuccess

func MakeSuccess(context *HttpContext) *HttpContext

func MakeSuccessResponse

func MakeSuccessResponse(
	context *HttpContext, data interface{}) *HttpContext

func (*HttpContext) GetCmd

func (this *HttpContext) GetCmd() string

func (*HttpContext) ID

func (this *HttpContext) ID() string

func (*HttpContext) Init

func (this *HttpContext) Init() error

Jump to

Keyboard shortcuts

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