Documentation
¶
Index ¶
- Constants
- Variables
- func Call(req *http.Request, client *http.Client) (response interface{}, err error)
- func ErrorToHttpCode(err error) int
- func HTTPErrorCode(err error) int
- func MakeUrl(host, path string, args string) (url string)
- func NewBytesRequest(method string, endpoint string, body []byte) (req *http.Request, err error)
- func NewJsonRequest(method string, endpoint string, body map[string]any) (req *http.Request, err error)
- func NewRequest(method string, endpoint string, bodyReader io.Reader) (req *http.Request, err error)
- func NormalizeWsUrl(httpOrWsUrl string) string
- func SendJsonResponse(writer http.ResponseWriter, resp interface{}, err error)
- func WSConnJSONReaderWriter(conn *websocket.Conn) (reader *conc.Reader[gut.StringMap], ...)
- func WSConnWriteError(wsConn *websocket.Conn, err error) error
- func WSConnWriteMessage(wsConn *websocket.Conn, msg interface{}) error
- func WSHandleConn[I any, S WSConn[I]](conn *websocket.Conn, ctx S, config *WSConnConfig)
- func WSServe[I any, S WSConn[I]](h WSHandler[I, S], config *WSConnConfig) http.HandlerFunc
- type BiDirStreamConfig
- type BiDirStreamConn
- type HTTPError
- type JSONConn
- func (j *JSONConn) ConnId() string
- func (j *JSONConn) DebugInfo() any
- func (j *JSONConn) HandleMessage(msg any) error
- func (j *JSONConn) Name() string
- func (j *JSONConn) OnClose()
- func (j *JSONConn) OnError(err error) error
- func (j *JSONConn) OnStart(conn *websocket.Conn) error
- func (j *JSONConn) OnTimeout() bool
- func (j *JSONConn) ReadMessage(conn *websocket.Conn) (out any, err error)
- func (j *JSONConn) SendPing() error
- type JSONHandler
- type RequestVarMap
- type URLWaiter
- type WSConn
- type WSConnConfig
- type WSHandler
Constants ¶
View Source
const ( ErrCodeInvalidRequest = 400 ErrCodeInvalidCredentials = 401 ErrCodeAuthorized = 403 ErrCodeEntityNotFound = 404 )
Variables ¶
View Source
var DefaultHttpClient *http.Client
View Source
var HighQPSHttpClient *http.Client
View Source
var LowQPSHttpClient *http.Client
View Source
var MediumQPSHttpClient *http.Client
Functions ¶
func ErrorToHttpCode ¶
func HTTPErrorCode ¶
func NewBytesRequest ¶
func NewJsonRequest ¶
func NewRequest ¶
func NormalizeWsUrl ¶ added in v0.0.90
func SendJsonResponse ¶
func SendJsonResponse(writer http.ResponseWriter, resp interface{}, err error)
func WSConnJSONReaderWriter ¶
func WSConnWriteMessage ¶
func WSHandleConn ¶
func WSHandleConn[I any, S WSConn[I]](conn *websocket.Conn, ctx S, config *WSConnConfig)
func WSServe ¶
func WSServe[I any, S WSConn[I]](h WSHandler[I, S], config *WSConnConfig) http.HandlerFunc
Types ¶
type BiDirStreamConfig ¶
func DefaultBiDirStreamConfig ¶
func DefaultBiDirStreamConfig() *BiDirStreamConfig
type BiDirStreamConn ¶
type BiDirStreamConn[I any] interface { /** * Called to send the next ping message. */ SendPing() error // Optional Name of the connection Name() string // Optional connection id ConnId() string /** * Called to handle the next message from the input stream on the ws conn. */ HandleMessage(msg I) error /** * Called to handle or suppress an error */ OnError(err error) error /** * Called when the connection closes. */ OnClose() OnTimeout() bool }
type JSONConn ¶
type JSONConn struct { Writer *conc.Writer[conc.Message[any]] NameStr string ConnIdStr string PingId int64 }
func (*JSONConn) HandleMessage ¶
*
- Called to handle the next message from the input stream on the ws conn.
type JSONHandler ¶
type JSONHandler struct { }
func (*JSONHandler) Validate ¶
func (j *JSONHandler) Validate(w http.ResponseWriter, r *http.Request) (out WSConn[any], isValid bool)
type RequestVarMap ¶ added in v0.0.88
type RequestVarMap struct {
// contains filtered or unexported fields
}
type URLWaiter ¶ added in v0.0.90
type URLWaiter struct { Method string Url string Headers map[string]string Payload map[string]any DelayBetweenChecks time.Duration // Func versions of above so we can do something dynamcially on each iteration RequestFunc func(iter int, prevError error) (*http.Request, error) ValidateFunc func(req *http.Request, resp *http.Response) error }
type WSConnConfig ¶
type WSConnConfig struct { *BiDirStreamConfig Upgrader websocket.Upgrader }
func DefaultWSConnConfig ¶
func DefaultWSConnConfig() *WSConnConfig
Click to show internal directories.
Click to hide internal directories.