goalpinejshandler

package module
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 10 Imported by: 8

README

go-alpinejs-handler

Documentation

Index

Constants

View Source
const ContentTypeKey = "Content-Type"

Variables

This section is empty.

Functions

func Register

func Register(router *http.ServeMux, config *Config)

func RegisterGlobalStyle added in v1.4.0

func RegisterGlobalStyle(style string)

func RegisterStyle added in v1.4.0

func RegisterStyle(name, style string)

Types

type ActionHandler

type ActionHandler interface {
	GetName() string
	GetActionType() string
	GetDefaultState() any
	Handle(msg Message, res http.ResponseWriter, req *http.Request, messagePool *MessagePool, tools *Tools)
}

type ChannelMessage

type ChannelMessage struct {
	ClientFilter func(client Client) bool
	Message      Message
}

type Client

type Client struct {
	ID           string
	ConnectionID string
	Response     http.ResponseWriter
	Request      *http.Request
}

func (*Client) SendMessage

func (ctx *Client) SendMessage(msg ChannelMessage)

type Component added in v1.4.0

type Component interface {
	Name() string
	Render() string
}

type Config

type Config struct {
	EventUrl                string
	ActionUrl               string
	ClientIDHeaderKey       string
	SocketReconnectInterval int
	Pages                   []Page
}

type Message

type Message struct {
	Type    string `json:"type"`
	Payload any    `json:"payload"`
}

type MessagePool

type MessagePool struct {
	// contains filtered or unexported fields
}

func (*MessagePool) Add

func (ctx *MessagePool) Add(msg ChannelMessage)

func (*MessagePool) Pull

func (ctx *MessagePool) Pull() chan ChannelMessage

type Page added in v1.4.0

type Page interface {
	Component
	Route() string
	Handlers() []ActionHandler
}

type Response

type Response struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
}

type Tools added in v1.2.0

type Tools struct {
	// contains filtered or unexported fields
}

func (*Tools) GetClientId added in v1.2.0

func (ctx *Tools) GetClientId(req *http.Request) string

func (*Tools) HasConnections added in v1.5.0

func (ctx *Tools) HasConnections(clientID string) bool

type ViewTools added in v1.4.0

type ViewTools struct{}

func (*ViewTools) Paint added in v1.4.0

func (ctx *ViewTools) Paint(tmpl Component) template.HTML

func (*ViewTools) Style added in v1.4.0

func (ctx *ViewTools) Style(names ...string) template.HTML

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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