websocket

package
v0.0.0-...-9fa121a Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandTypeGet    = "get"
	CommandTypeUpdate = "update"
	CommandTypeCreate = "create"
	CommandTypeDelete = "delete"
)

Variables

This section is empty.

Functions

func ServeWs

func ServeWs(hub *Hub, c WSController, w http.ResponseWriter, r *http.Request)

serveWs handles websocket requests from the peer.

Types

type Client

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

Client is a middleman between the websocket connection and the hub.

type ClientResponse

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

type Command

type Command struct {
	Command string      `json:"command"`
	Data    interface{} `json:"data"`
	// contains filtered or unexported fields
}

type CommandType

type CommandType string

type Hub

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

func NewHub

func NewHub() *Hub

func (*Hub) Run

func (h *Hub) Run()

type Response

type Response struct {
	Status Status      `json:"status"`
	Value  interface{} `json:"value"`
}

type Status

type Status int
const (
	StatusSuccess Status = 200
	StatusCreated Status = 201

	StatusInternalServerError Status = 500

	StatusBadRequest Status = 400
	StatusNotFound   Status = 404
	StatusConflict   Status = 409
)

type WSController

type WSController struct {
	FlagService flags.FlagService
	CacheClient storage.CacheClient
}

func (WSController) Create

func (ws WSController) Create(cmd *Command) Response

func (WSController) Delete

func (ws WSController) Delete(cmd *Command) Response

func (WSController) Get

func (ws WSController) Get(c *Command) Response

func (WSController) RunCommand

func (ws WSController) RunCommand(cmd *Command) Response

func (WSController) Update

func (ws WSController) Update(cmd *Command) Response

Jump to

Keyboard shortcuts

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