utils

package
v0.0.0-...-1e93ed8 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(uri string, headers Headers) ([]byte, error)

func GetForm

func GetForm[T any](uri string, headers Headers) (*T, error)

func MarshalForm

func MarshalForm(data interface{}) string

func Post

func Post(uri string, headers Headers, body string) ([]byte, error)

func PostForm

func PostForm[T any](uri string, headers Headers, body interface{}) (*T, error)

func ReadForm

func ReadForm[T interface{}](w *WebSocket) *T

func TrimPrefixes

func TrimPrefixes(s string, prefixes ...string) string

func UnmarshalByteForm

func UnmarshalByteForm[T any](data []byte) (*T, error)

func UnmarshalForm

func UnmarshalForm[T any](data string) *T

Types

type Headers

type Headers map[string]string

type WebSocket

type WebSocket struct {
	Conn   *websocket.Conn
	Cursor int
}

func NewWebsocket

func NewWebsocket(url string) (ws *WebSocket, err error)

func (*WebSocket) Close

func (w *WebSocket) Close() error

func (*WebSocket) DeferClose

func (w *WebSocket) DeferClose()

func (*WebSocket) GetCursor

func (w *WebSocket) GetCursor() int

func (*WebSocket) IncrCursor

func (w *WebSocket) IncrCursor()

func (*WebSocket) IsEmpty

func (w *WebSocket) IsEmpty() bool

func (*WebSocket) NextWriter

func (w *WebSocket) NextWriter(messageType int) (io.WriteCloser, error)

func (*WebSocket) Read

func (w *WebSocket) Read() (int, []byte, error)

func (*WebSocket) ReadJSON

func (w *WebSocket) ReadJSON(v interface{}) error

func (*WebSocket) Receive

func (w *WebSocket) Receive(v interface{}) bool

func (*WebSocket) Send

func (w *WebSocket) Send(v interface{}) bool

func (*WebSocket) SendJSON

func (w *WebSocket) SendJSON(v interface{}) error

func (*WebSocket) SendText

func (w *WebSocket) SendText(message string) bool

func (*WebSocket) Write

func (w *WebSocket) Write(messageType int, data []byte) error

Jump to

Keyboard shortcuts

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