server

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

spell-checker: disable

spell-checker: disable

spell-checker: disable

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fuse

func Fuse(restfulPort, grpcPort int, autoRecover bool, withErr bool, routes func(router FuseRouter))

func Fuse2 added in v1.1.37

func Fuse2(restfulPort, grpcPort int, autoRecover bool, withErr bool, routes func(router FuseRouter), grpcRegister ...func(svc *grpc.Server))

func SetFuseStatusMessage

func SetFuseStatusMessage(call func(status *FuseDefaultStatus, message *FuseDefaultMessage))

Types

type ClientFuseGRPC

type ClientFuseGRPC interface {
	Restful(path string, header map[string]string, payload map[string]interface{}, params map[string]string) (*grf.Response, error)
}

func ConnectFuseGRPC

func ConnectFuseGRPC(address string) (ClientFuseGRPC, error)

type FuseContext

type FuseContext interface {
	URI() string
	Request() FuseContextRequest
	Params(key string, defaultValue ...string) string
	Query(key string, defaultValue ...string) string
	Parser(logc *clog.Instance, header, body interface{}) (bool, error)
	GetMultipartFiles() map[string][]*multipart.FileHeader
	ClientIP() string
	Path() string
	Method() string

	AuthX() interface{}
	AuthY() interface{}
	AuthZ() interface{}
	SetAuth(authX, authY, authZ interface{})

	SetCLog(logc *clog.Instance)
	GetCLog() *clog.Instance

	GetResCode() (int, string)
	GetResObject() interface{}
	SetResponse(code int, subCode string, obj interface{}) error
	SR200OK(subCode string, obj interface{}) error
	SR400BadRequest(subCode string, obj interface{}) error
	SR401Unauthorized(subCode string, obj interface{}) error
	SR403Forbidden(subCode string, obj interface{}) error
	SR404NotFound(subCode string, obj interface{}) error
	SR406NotAcceptable(subCode string, obj interface{}) error
	SR428PreconditionRequired(subCode string, obj interface{}) error
	SR500InternalServerError(subCode string, obj interface{}) error

	RString(logc *clog.Instance, code int, data string) error
	RJson(logc *clog.Instance, code int, data interface{}, opt ...FuseOpt) error
	RJsonRaw(logc *clog.Instance, code int, data []byte) error

	Redirect(logc *clog.Instance, code int, url string) error
	RXXX(logc *clog.Instance, code int, status string, data interface{}, opt ...FuseOpt) error
	R200OK(logc *clog.Instance, data interface{}, opt ...FuseOpt) error
	R400BadRequest(logc *clog.Instance, message string, opt ...FuseOpt) error
	R401Unauthorized(logc *clog.Instance, message string, opt ...FuseOpt) error
	R403Forbidden(logc *clog.Instance, message string, opt ...FuseOpt) error
	R404NotFound(logc *clog.Instance, message string, opt ...FuseOpt) error
	R406NotAcceptable(logc *clog.Instance, message string, opt ...FuseOpt) error
	R428PreconditionRequired(logc *clog.Instance, message string, opt ...FuseOpt) error
	R500InternalServerError(logc *clog.Instance, err error, opt ...FuseOpt) error

	SetSendResponse(send bool)
	GetUnSendResponse() *FuseResponse
	GetUnSendResponseOpt() []FuseOpt
}

type FuseContextRequest added in v1.1.16

type FuseContextRequest interface {
	Body() []byte
	Header() map[string]string
	SetHeader(key, value string)
}

type FuseDefaultMessage

type FuseDefaultMessage struct {
	R400BadRequest           string
	R401Unauthorized         string
	R403Forbidden            string
	R404NotFound             string
	R406NotAcceptable        string
	R428PreconditionRequired string
	R500InternalServerError  string
}

type FuseDefaultStatus

type FuseDefaultStatus struct {
	R200OK                   string
	R400BadRequest           string
	R401Unauthorized         string
	R403Forbidden            string
	R404NotFound             string
	R406NotAcceptable        string
	R428PreconditionRequired string
	R500InternalServerError  string
}

type FuseOpt

type FuseOpt struct {
	SubCode            string
	Status             string
	Message            string
	Address            string
	Error              error
	MetaData           interface{}
	Data               interface{}
	NewMeta            map[string]interface{}
	NewHeader          map[string]interface{}
	LogMessage         string
	LogData            string
	LogDepthAdd        int
	JsonCustomOutput   bool
	StringCustomOutput bool
	// contains filtered or unexported fields
}

type FuseResponse added in v1.1.48

type FuseResponse struct {
	Meta FuseResponseMeta `json:"meta"`
	Data interface{}      `json:"data,omitempty"`
}

type FuseResponseMeta added in v1.1.48

type FuseResponseMeta struct {
	Code    int         `json:"code"`
	SubCode string      `json:"subcode,omitempty"`
	Status  string      `json:"status,omitempty"`
	Message string      `json:"message,omitempty"`
	Address string      `json:"address,omitempty"`
	Error   string      `json:"error,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

type FuseRouter

type FuseRouter interface {
	Unrouted(handler func(ctx FuseContext, method, path, url string) error)
	Single(path string, handlers ...func(sc FuseContext) error)
	Group(endpoints map[string][]func(sc FuseContext) error)
}

Directories

Path Synopsis
proto

Jump to

Keyboard shortcuts

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