lhttp

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrStatus

func ErrStatus(err error) int

ErrStatus will return 0 if err is nil. If err is not nil and fulfills StatusErr, that Status will be returned, otherwise StatusInternalServerError is returned.

Types

type ChanHandler

type ChanHandler func(to chan<- []byte, from <-chan []byte, r *http.Request)

ChanHandler represents duplex communication with two channels.

type ErrHandler

type ErrHandler func(w http.ResponseWriter, r *http.Request, err error)

ErrHandler is intended to repsond to a request when an error has occured.

func (ErrHandler) Check

func (h ErrHandler) Check(w http.ResponseWriter, r *http.Request, err error) bool

Check only invokes the ErrHandler if err is not nil. Returns a bool indicating if ErrHandler was invoked.

type MessageReaderWriter

type MessageReaderWriter interface {
	WriteMessage(messageType int, data []byte) error
	ReadMessage() (int, []byte, error)
}

type RequestDecoder

type RequestDecoder interface {
	Decode(interface{}, *http.Request) error
}

RequestDecoder encapsulates decoding a request to a value

type Socket

type Socket struct {
	MessageReaderWriter
	// contains filtered or unexported fields
}

Socket is intended to be a websocket

func NewSocket

func NewSocket(socket MessageReaderWriter) *Socket

NewSocket creates a Socket. It is intended to be used with a websocket.

func (*Socket) Read

func (socket *Socket) Read(p []byte) (n int, err error)

func (*Socket) Write

func (socket *Socket) Write(p []byte) (n int, err error)

type SocketHandler

type SocketHandler func(*websocket.Conn, *http.Request)

SocketHandler is similar to http.HandlerFunc, but for handling websockets

type StatusErr

type StatusErr interface {
	Status() int
}

StatusErr provides an optional interface for errors allowing errors to include HTTP status.

Directories

Path Synopsis
Package midware provides a way to convert a MidwareFunc to an http.HandlerFunc.
Package midware provides a way to convert a MidwareFunc to an http.HandlerFunc.

Jump to

Keyboard shortcuts

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