Documentation ¶
Index ¶
- Variables
- func BadRequest(resp *Message)
- func Error(resp *Message, code StatusCode)
- func InternalServerError(resp *Message)
- func Push(url string, msg Message) (err error)
- func PushCtx(ctx context.Context, url string, msg Message) (err error)
- func StartSrv(srv *Server)
- func StopSrv(srv *Server)
- type Content
- type DataPush
- type DataRequest
- type DataRequestBuilder
- type DataResponse
- type DataResponseBuilder
- type Handler
- type HandlerFunc
- type Matcher
- type Message
- type MessageBuilder
- type MessageID
- type MessageType
- type Paragraph
- type ParagraphType
- type PostError
- type ServeMux
- type Server
- type StatusCode
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultServeMux = NewServeMux()
Functions ¶
func BadRequest ¶ added in v0.4.0
func BadRequest(resp *Message)
func Error ¶ added in v0.3.0
func Error(resp *Message, code StatusCode)
func InternalServerError ¶ added in v0.4.0
func InternalServerError(resp *Message)
Types ¶
type DataRequest ¶ added in v0.3.0
type DataRequest[Action ~uint8] struct { Action Action `json:"action"` Args json.RawMessage `json:"args"` }
type DataRequestBuilder ¶ added in v0.3.0
type DataResponse ¶ added in v0.3.0
type DataResponse struct { StatusCode StatusCode `json:"status_code"` Values json.RawMessage `json:"values"` }
type DataResponseBuilder ¶ added in v0.3.0
type DataResponseBuilder[Values any] struct { StatusCode StatusCode `json:"status_code"` Values Values `json:"values"` }
type Handler ¶
func MultiHandler ¶ added in v0.4.0
type HandlerFunc ¶
func (HandlerFunc) ServeMessage ¶ added in v0.3.0
func (h HandlerFunc) ServeMessage(resp *Message, post Message)
type Message ¶ added in v0.3.0
type Message struct { Type MessageType `json:"type"` Data json.RawMessage `json:"data"` Content Content `json:"content"` }
func SendMessage ¶ added in v0.3.0
type MessageBuilder ¶ added in v0.3.0
type MessageBuilder[Data any] struct { Type MessageType `json:"type"` Data Data `json:"data"` Content []Paragraph `json:"content"` }
func (*MessageBuilder[Data]) Message ¶ added in v0.3.0
func (b *MessageBuilder[Data]) Message() (msg Message, err error)
func (*MessageBuilder[Data]) Write ¶ added in v0.3.0
func (b *MessageBuilder[Data]) Write(w *Message) (err error)
type MessageType ¶ added in v0.3.0
type MessageType uint8
const ( MessagePush MessageType = iota + 1 MessageRequest MessageResponse )
func (MessageType) String ¶ added in v0.3.0
func (typ MessageType) String() (str string)
type Paragraph ¶ added in v0.3.0
type Paragraph struct { Type ParagraphType `json:"type" bson:"type,omitempty"` Text string `json:"text" bson:"text,omitempty"` Name string `json:"name" bson:"name,omitempty"` Ref string `json:"ref" bson:"ref,omitempty"` }
type ParagraphType ¶ added in v0.3.0
type ParagraphType uint8
const ( ParagraphText ParagraphType = iota + 1 ParagraphImage ParagraphRecord ParagraphVideo )
type PostError ¶ added in v0.3.0
type PostError interface { error StatusCode() StatusCode }
type ServeMux ¶
type ServeMux struct {
// contains filtered or unexported fields
}
func NewServeMux ¶
func NewServeMux() *ServeMux
func (*ServeMux) ServeMessage ¶ added in v0.3.0
type Server ¶
func (*Server) ListenAndServe ¶
type StatusCode ¶ added in v0.3.0
type StatusCode uint8
const ( StatusOK StatusCode = iota + 1 StatusBadRequest StatusInternalServerError )
func (StatusCode) String ¶ added in v0.3.0
func (c StatusCode) String() string
func (StatusCode) Text ¶ added in v0.3.0
func (c StatusCode) Text() string
Click to show internal directories.
Click to hide internal directories.