api

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const StreamNotFound = "stream not found"

Variables

This section is empty.

Functions

func HandleFunc

func HandleFunc(pattern string, handler http.HandlerFunc)

HandleFunc handle pattern with relative path: - "api/streams" => "{basepath}/api/streams" - "/streams" => "/streams"

func HandleWS

func HandleWS(msgType string, handler WSHandler)

func Init

func Init()

Types

type Message

type Message struct {
	Type  string      `json:"type"`
	Value interface{} `json:"value,omitempty"`
}

Message - struct for data exchange in Web API

type Transport

type Transport struct {
	Request  *http.Request
	Consumer interface{} // TODO: rewrite
	// contains filtered or unexported fields
}

func (*Transport) Close

func (t *Transport) Close()

func (*Transport) OnChange

func (t *Transport) OnChange(f func())

func (*Transport) OnClose

func (t *Transport) OnClose(f func())

func (*Transport) OnWrite

func (t *Transport) OnWrite(f func(msg interface{}))

func (*Transport) Write

func (t *Transport) Write(msg interface{})

type WSHandler

type WSHandler func(tr *Transport, msg *Message) error

Jump to

Keyboard shortcuts

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