models

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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
}

func NewBroker added in v0.0.17

func NewBroker(address string, brokerPort, wsPort int) (b *Broker, err error)

func (*Broker) Publish added in v0.0.17

func (b *Broker) Publish(topic string, payload any) (err error)

func (*Broker) ServeWS added in v0.0.17

func (b *Broker) ServeWS(w http.ResponseWriter, r *http.Request)

func (*Broker) Subscribe added in v0.0.17

func (b *Broker) Subscribe(topic string, cb func(msg MQTTMessage)) error

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 (c *Context) GetParameter(key string) string

func (*Context) GetRequest

func (c *Context) GetRequest() *http.Request

func (*Context) GetResponseWriter

func (c *Context) GetResponseWriter() http.ResponseWriter

func (*Context) RespondJson

func (c *Context) RespondJson(statusCode int, data any)

func (*Context) RespondString

func (c *Context) RespondString(s string)

func (*Context) SetParameters

func (c *Context) SetParameters(p map[string]string)

func (*Context) SetRequest

func (c *Context) SetRequest(r *http.Request)

func (*Context) SetResponseWriter

func (c *Context) SetResponseWriter(w http.ResponseWriter)

type Group

type Group struct {
	Path  string
	Route *Route
	// contains filtered or unexported fields
}

func (*Group) AddMiddleware added in v0.3.2

func (g *Group) AddMiddleware(mw ...Middleware) *Group

AddMiddleware registers middleware specifically for this group

func (*Group) Broadcast added in v0.3.0

func (g *Group) Broadcast(path string, messageType int, data []byte, sender *websocket.Conn)

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) NewBroker added in v0.3.0

func (g *Group) NewBroker(path string, address string, brokerPort, wsPort int) (b *Broker, err error)

func (*Group) NewGroup added in v0.3.0

func (g *Group) NewGroup(path string) *Group

func (*Group) NewWebSocket added in v0.3.0

func (g *Group) NewWebSocket(path string) (client *WSClient)

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

func (g *Group) ServeFile(path, file string)

ServeFile serves a single static file under this group's path prefix

func (*Group) ServeFileSystem added in v0.3.0

func (g *Group) ServeFileSystem(path, directory string)

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 MQTTMessage struct {
	ID            string `json:"uuid,omitempty"`
	RemoteAddress string `json:"remoteAddress,omitempty"`
	Topic         string `json:"topic"`
	Payload       string `json:"payload"`
}

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(next HandlerFunc) HandlerFunc

Middleware defines our custom middleware constructor signature

func BearerAuthMiddleware added in v0.3.2

func BearerAuthMiddleware(validateToken func(token string) bool) Middleware

BearerAuthMiddleware validates incoming Authorization: Bearer <token> headers. It accepts a validator function so you can inject custom JWT or database token checks.

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)

func (*Route) Search

func (n *Route) Search(method, path string) (bool, HandlerFunc, map[string]string)

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)

func (*WSClient) Listen added in v0.0.16

func (ws *WSClient) Listen(cb func(data any))

func (*WSClient) NewConn added in v0.3.0

func (ws *WSClient) NewConn(conn *websocket.Conn)

func (*WSClient) Recieve added in v0.0.16

func (ws *WSClient) Recieve(data any)

func (*WSClient) SetConnection added in v0.0.16

func (ws *WSClient) SetConnection(conn *websocket.Conn)

Jump to

Keyboard shortcuts

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