server

package
v1.0.41 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cron added in v1.0.24

func Cron(routes func(router RouterC))

func FuseG

func FuseG(grpcPort int, routes func(router RouterG))

func FuseGR

func FuseGR(grpcPort int, grpcRoutes func(router RouterG), restPort int, restRoutes func(router RouterR))

func FuseGS added in v1.0.30

func FuseGS(grpcPort int, grpcRoutes func(router RouterG), wsPort int, wsRoutes func(router RouterS))

func FuseR

func FuseR(restPort int, routes func(router RouterR))

func FuseRS added in v1.0.22

func FuseRS(restPort int, routes func(router RouterR), ws func(router RouterS))

func WsStream added in v1.0.30

func WsStream(logc clog.Instance, addr string, header *map[string]string, connectedMessage string, callback func(logc clog.Instance, message string), async ...bool)

Types

type FuseRCallOpt

type FuseRCallOpt interface {
	OverrideHeader(val map[string]string) FuseRCallOpt
	OverrideParam(val map[string]string) FuseRCallOpt
	OverrideQuery(val map[string]string) FuseRCallOpt
	OverrideForm(val map[string][]string) FuseRCallOpt
}

type FuseRContext

type FuseRContext interface {
	Clog() clog.Instance
	Auth(obj ...any) any
	UserId(id ...any) any
	PartnerId(id ...any) any
	SetFiles(files map[string]string)

	ReqHeader() *map[string]string
	ReqParam() *map[string]string
	ReqQuery() *map[string]string
	ReqForm() *map[string][]string
	ReqFile() *map[string][]*multipart.FileHeader

	GetHeader(key string, dval ...string) *string
	GetClientIP() string
	RouteMethod() string
	RoutePath() string

	ReqParser(header any, body any) error
	ReqParserPQF(param any, query any, form any) error

	LastResponse() (val any, meta ResponseMeta)

	R200OK(val any, opt ...ResponseOpt) any
	R201Created(val any, opt ...ResponseOpt) any
	R202Accepted(val any, opt ...ResponseOpt) any
	R204NoContent(val any, opt ...ResponseOpt) any

	R301MovedPermanently(val any, opt ...ResponseOpt) any
	R307TemporaryRedirect(val any, opt ...ResponseOpt) any
	R308PermanentRedirect(val any, opt ...ResponseOpt) any

	R400BadRequest(val any, opt ...ResponseOpt) any
	R401Unauthorized(val any, opt ...ResponseOpt) any
	R403Forbidden(val any, opt ...ResponseOpt) any
	R404NotFound(val any, opt ...ResponseOpt) any
	R406NotAcceptable(val any, opt ...ResponseOpt) any
	R412PreconditionFailed(val any, opt ...ResponseOpt) any
	R418Teapot(val any, opt ...ResponseOpt) any
	R428PreconditionRequired(val any, opt ...ResponseOpt) any

	R500InternalServerError(err error, opt ...ResponseOpt) any
	R503ServiceUnavailable(val any, opt ...ResponseOpt) any
}

type FuseRContextBuilder

type FuseRContextBuilder interface {
	Build() FuseRContext
}

type FuseRRegulator

type FuseRRegulator interface {
	Next() (next bool, handler func(ctx FuseRContext) any)
	IsHandler(handler func(ctx FuseRContext) any) bool
	Call(handler func(ctx FuseRContext) any, opt ...FuseRCallOpt) (res any, meta ResponseMeta, raw bool)
	CallOpt() FuseRCallOpt
	Endpoint() string
	Recover()
}

type FuseSContext added in v1.0.22

type FuseSContext interface {
	ReadMessage() (message string, err error)
	WriteMessage(message string) error
	GetLocal(key string) string
	GetParam(key string) string
	GetQuery(key string) string
	Close()
}

type FuseSLocal added in v1.0.22

type FuseSLocal interface {
	Set(key string, header ...string)
}

type FuseSRun added in v1.0.30

type FuseSRun interface {
	Broadcast(message string)
	BroadcastUser(userUid string, message string)
}

type Response added in v1.0.5

type Response struct {
	Meta ResponseMeta `json:"meta"`
	Data any          `json:"data,omitempty"`
}

type ResponseMeta added in v1.0.5

type ResponseMeta struct {
	Code       int    `json:"code"`
	SubCode    string `json:"sub_code,omitempty"`
	Message    string `json:"message,omitempty"`
	AppMessage string `json:"app_message,omitempty"`
}

type ResponseOpt added in v1.0.5

type ResponseOpt struct {
	SubCode      string
	Message      string
	AppMessage   string
	RawResponse  bool
	ResponseType *string
}

type RouterC added in v1.0.24

type RouterC interface {
	// duration like `1m` for every 1 minute, `2h` for every 2 hours.
	// valid time units: "s", "m", "h".
	Every(duration string, fn func(), startUpDelayed *time.Duration, allowParallel ...bool)

	// duration like `1m` for every 1 minute, `2h` for every 2 hours.
	// valid time units: "s", "m", "h".
	NEvery(duration string, fns []func(), startUpDelayed *time.Duration, allowParallel ...bool)

	// at a specific time of day in the form "HH:MM:SS" or "HH:MM".
	EveryDay(at string, fn func(), allowParallel ...bool)

	// at a specific time of day in the form "HH:MM:SS" or "HH:MM".
	NEveryDay(at string, fns []func(), allowParallel ...bool)
}

type RouterG

type RouterG interface {
	AutoRecover(autoRecover bool)
	Server() *grpc.Server
	RunHealthCheck()
}

type RouterR

type RouterR interface {
	AutoRecover(autoRecover bool)
	PrintOnError(printOnError bool)
	Unrouted(handler func(ctx FuseRContext, method, path, url string) any)

	ErrorHandler(catcher func(ctx FuseRContext, err error) any)
	NoLog(paths []string)
	Endpoints(regulator func(regulator FuseRRegulator), auth func(FuseRContext) any, pathHandlers map[string][]func(FuseRContext) any)
	Static(endpointPaths map[string]string, config ...fiber.Static)
}

type RouterS added in v1.0.22

type RouterS interface {
	Locals(fn func(sl FuseSLocal))
	Register(path string, handler func(ctx FuseSContext))
	Run(path string, registerCondition *func(ctx FuseSContext) bool, userUidCondition *func(ctx FuseSContext) (ok bool, userUid string)) FuseSRun
}

Jump to

Keyboard shortcuts

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