Documentation
¶
Index ¶
- type Broker
- type CORSMiddleware
- type Context
- func (c *Context) GetParameter(key string) string
- func (c *Context) GetRequest() *http.Request
- func (c *Context) GetResponseWriter() http.ResponseWriter
- func (c *Context) RespondJson(statusCode int, data any)
- func (c *Context) RespondString(s string)
- func (c *Context) SetParameters(p map[string]string)
- func (c *Context) SetRequest(r *http.Request)
- func (c *Context) SetResponseWriter(w http.ResponseWriter)
- type Group
- func (g *Group) Broadcast(path string, messageType int, data []byte, sender *websocket.Conn)
- func (g *Group) Delete(path string, handler HandlerFunc)
- func (g *Group) Get(path string, handler HandlerFunc)
- func (g *Group) NewBroker(path string, address string, brokerPort, wsPort int) (b *Broker, err error)
- func (g *Group) NewGroup(path string) *Group
- func (g *Group) NewWebSocket(path string) (client *WSClient)
- func (g *Group) Post(path string, handler HandlerFunc)
- func (g *Group) Put(path string, handler HandlerFunc)
- func (g *Group) ServeFile(path, file string)
- func (g *Group) ServeFileSystem(path, directory string)
- func (g *Group) Update(path string, handler HandlerFunc)
- type HandlerFunc
- type MQTTMessage
- type MessageType
- type Middleware
- type Route
- type WSClient
- func (ws *WSClient) Answer(messageType MessageType, data []byte)
- func (ws *WSClient) Broadcast(messageType MessageType, data []byte)
- func (ws *WSClient) Listen(cb func(data any))
- func (ws *WSClient) NewConn(conn *websocket.Conn)
- func (ws *WSClient) Recieve(data any)
- func (ws *WSClient) SetConnection(conn *websocket.Conn)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶ added in v0.0.17
type Broker struct {
// contains filtered or unexported fields
}
type CORSMiddleware ¶ added in v0.3.0
type CORSMiddleware struct {
AllowOrigins string
AllowMethods string
AllowHeaders string
AllowPrivateNetwork string
}
func DefaultCORS ¶ added in v0.3.0
func DefaultCORS() *CORSMiddleware
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) GetParameter ¶
func (*Context) GetRequest ¶
func (*Context) GetResponseWriter ¶
func (c *Context) GetResponseWriter() http.ResponseWriter
func (*Context) RespondJson ¶
func (*Context) RespondString ¶
func (*Context) SetParameters ¶
func (*Context) SetRequest ¶
func (*Context) SetResponseWriter ¶
func (c *Context) SetResponseWriter(w http.ResponseWriter)
type Group ¶
func (*Group) Delete ¶ added in v0.0.15
func (g *Group) Delete(path string, handler HandlerFunc)
func (*Group) Get ¶
func (g *Group) Get(path string, handler HandlerFunc)
func (*Group) NewWebSocket ¶ added in v0.3.0
func (*Group) Post ¶
func (g *Group) Post(path string, handler HandlerFunc)
func (*Group) Put ¶ added in v0.0.15
func (g *Group) Put(path string, handler HandlerFunc)
func (*Group) ServeFile ¶ added in v0.3.0
ServeFile serves a single static file under this group's path prefix
func (*Group) ServeFileSystem ¶ added in v0.3.0
ServeFileSystem serves a static folder under this group's path prefix
func (*Group) Update ¶ added in v0.0.15
func (g *Group) Update(path string, handler HandlerFunc)
type HandlerFunc ¶ added in v0.1.0
type HandlerFunc func(ctx Context)
func Chain ¶ added in v0.1.0
func Chain(handler HandlerFunc, middlewares ...Middleware) HandlerFunc
func LoggingMiddleware ¶ added in v0.1.0
func LoggingMiddleware(next HandlerFunc) HandlerFunc
LoggingMiddleware is an example of a custom middleware
type MQTTMessage ¶ added in v0.0.17
type MessageType ¶ added in v0.2.0
type MessageType int
const ( // TextMessage denotes a text data message. The text message payload is // interpreted as UTF-8 encoded text data. TextMessage MessageType = 1 // BinaryMessage denotes a binary data message. BinaryMessage MessageType = 2 // CloseMessage denotes a close control message. The optional message // payload contains a numeric code and text. Use the FormatCloseMessage // function to format a close message payload. CloseMessage MessageType = 8 // PingMessage denotes a ping control message. The optional message payload // is UTF-8 encoded text. PingMessage MessageType = 9 // PongMessage denotes a pong control message. The optional message payload // is UTF-8 encoded text. PongMessage MessageType = 10 )
The message types are defined in RFC 6455.
type Middleware ¶ added in v0.1.0
type Middleware func(HandlerFunc) HandlerFunc
Middleware defines our custom middleware constructor signature
type Route ¶
type Route struct {
Cors *CORSMiddleware
Connections sync.Map
// contains filtered or unexported fields
}
func (*Route) Insert ¶
func (n *Route) Insert(method, path string, handler HandlerFunc)
type WSClient ¶ added in v0.0.16
type WSClient struct {
Send func(messageType MessageType, data []byte)
NewConnection func(ws *WSClient)
// contains filtered or unexported fields
}
func (*WSClient) Answer ¶ added in v0.0.16
func (ws *WSClient) Answer(messageType MessageType, data []byte)
func (*WSClient) Broadcast ¶ added in v0.2.0
func (ws *WSClient) Broadcast(messageType MessageType, data []byte)