Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdapterManager ¶
type AdapterManager struct {
App *App
HttpAdapter BaseHTTPAdapter
SocketAdapter BaseSocketAdapter
}
func (*AdapterManager) EsureAdapter ¶
func (m *AdapterManager) EsureAdapter(adapterType string)
func (*AdapterManager) UseHttpAdapter ¶
func (m *AdapterManager) UseHttpAdapter(adapter BaseHTTPAdapter)
func (*AdapterManager) UseSocketAdapter ¶
func (m *AdapterManager) UseSocketAdapter(adapter BaseSocketAdapter)
type App ¶
type App struct {
Adapter *AdapterManager
HttpAdapter BaseHTTPAdapter
SocketAdapter BaseSocketAdapter
}
type BaseHTTPAdapter ¶
type BaseSocketAdapter ¶
type BaseSocketAdapter interface {
GetName() string
Init() error
Start() error
GetRoom(id string) *SocketRoom
CreateRoom(id string) (*SocketRoom, error)
JoinRoom(id string, client *SocketSession) error
On(event string, handler SocketEventHandler)
Emit(client *SocketSession, message *SocketEventMessage) error
Stop() error
HTTPHandler() func(http.ResponseWriter, *http.Request)
}
type HttpController ¶
func InitHttpController ¶
func InitHttpController(app *App, module *Module) *HttpController
func (*HttpController) Route ¶
func (m *HttpController) Route(method string, path string, handler RouteHandler) *Route
func (*HttpController) RouteSocket ¶ added in v0.0.3
func (m *HttpController) RouteSocket(path string) error
type Request ¶
type Request interface {
GetHeader(name string) string
GetCookie(name string) (string, error)
GetIP() string
GetQuery(key string) string
GetParam(key string) string
GetFormValue(key string) string
GetBody() ([]byte, error)
Method() string
Path() string
Host() string
URL() string
ContentType() string
BindJSON(obj interface{}) error
BindForm(obj interface{}) error
BindQuery(obj interface{}) error
Context() any
FormFile(name string) (any, error)
}
type Response ¶
type Response interface {
SetHeader(name string, value string)
SetStatus(code int)
SetCookie(name string, value string, path string, maxAge int)
JSON(code int, obj interface{}) error
Text(code int, msg string) error
HTML(code int, html string) error
Blob(code int, contentType string, data []byte) error
Redirect(code int, url string) error
SendFile(filePath string) error
Writer() any
}
type RouteHandler ¶
type SocketController ¶ added in v0.0.3
type SocketController struct {
App *App
Module *Module
SocketAdapter BaseSocketAdapter
}
func InitSocketController ¶ added in v0.0.3
func InitSocketController(app *App, module *Module) *SocketController
func (*SocketController) On ¶ added in v0.0.3
func (c *SocketController) On(event string, handler SocketEventHandler)
type SocketEventHandler ¶
type SocketEventHandler func(client *SocketSession, msg *SocketEventMessage)
type SocketEventMessage ¶ added in v0.0.3
type SocketEventMessage struct {
Event string `json:"event"`
Data interface{} `json:"data"`
}
type SocketRoom ¶ added in v0.0.3
type SocketRoom struct {
Adapter BaseSocketAdapter
RoomID string
Data map[string]any
Clients map[string]*SocketSession
}
func (*SocketRoom) Emit ¶ added in v0.0.3
func (r *SocketRoom) Emit(client *SocketSession, msg *SocketEventMessage) error
func (*SocketRoom) EmitAll ¶ added in v0.0.3
func (r *SocketRoom) EmitAll(msg *SocketEventMessage) error
func (*SocketRoom) HasClient ¶ added in v0.0.3
func (r *SocketRoom) HasClient(clientID string) bool
Source Files
¶
Click to show internal directories.
Click to hide internal directories.