server

package
v0.0.0-...-15a7b9f Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS_EMPTY_RESPONSE = "success"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AppID          string `json:"app_id"`           //appid
	AppSecret      string `json:"app_secret"`       //appsecret
	Token          string `json:"token"`            //token
	EncodingAESKey string `json:"encoding_aes_key"` //EncodingAESKey
}

type Guard

type Guard interface {
	Resolve(message *Message) bool
	ShouldReturnRawResponse() bool
}

type Handler

type Handler interface {
	Handle(message *Message) interface{}
}

Handler is interface to handle message

type HandlerFunc

type HandlerFunc func(*Message) interface{}

HandlerFunc

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(m *Message) interface{}

Handle by func

type Server

type Server struct {
	*Config
	Writer  http.ResponseWriter
	Request *http.Request
}

type ServerGuard

type ServerGuard struct {
	Guard          Guard
	Config         Config
	Request        *ehttp.Request
	AlwaysValidate bool
	Response       *ehttp.Response
	Logger         *log.Logger
	Encryptor      *encryptor.Encryptor

	MuxEntry     *gmap.IntAnyMap
	MessageGroup *gmap.StrIntMap
	// contains filtered or unexported fields
}

func New

func New(config Config, request *http.Request, writer http.ResponseWriter) *ServerGuard

New

func (*ServerGuard) Dispatch

func (s *ServerGuard) Dispatch(mtype string, message *Message)

func (*ServerGuard) ForceValidate

func (s *ServerGuard) ForceValidate() *ServerGuard

ForceValidate set to force validation the request

func (*ServerGuard) GetHandlers

func (s *ServerGuard) GetHandlers() *gmap.IntAnyMap

GetHandlers

func (*ServerGuard) GetMessage

func (s *ServerGuard) GetMessage() (message *Message, err error)

GetMessage

func (*ServerGuard) HandleRequest

func (s *ServerGuard) HandleRequest(originMsg *Message)

return response

func (*ServerGuard) IsSafeMode

func (s *ServerGuard) IsSafeMode() bool

IsSafeMode check the request message is the safe mode.

func (*ServerGuard) Push

func (s *ServerGuard) Push(handler Handler, pattern message.MessageType)

Push

func (*ServerGuard) PushFunc

func (s *ServerGuard) PushFunc(handler HandlerFunc, pattern message.MessageType)

PushFunc

func (*ServerGuard) RegisterMessageType

func (s *ServerGuard) RegisterMessageType(message map[string]message.MessageType)

Register message type

func (*ServerGuard) Serve

func (s *ServerGuard) Serve()

Serve

func (*ServerGuard) TypeToEvent

func (s *ServerGuard) TypeToEvent(t string) message.MessageType

TypeToEvent

func (*ServerGuard) Validate

func (s *ServerGuard) Validate() *ServerGuard

Validate validate request source

Jump to

Keyboard shortcuts

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