Documentation
¶
Index ¶
- Variables
- func NewMethod(nsid syntax.NSID, typ RequestType) *rpcMethod
- func NewReqBuilder() *requestBuilder
- func Stream[T any](ctx context.Context, c *websocket.Conn, seq iter.Seq[T]) (err error)
- func WriteError(l *slog.Logger, w http.ResponseWriter, err error, defaultStatus Code)
- func WriteInvalidRequest(l *slog.Logger, w http.ResponseWriter, err error, msg string, args ...any)
- type Auth
- type Client
- type ClientOption
- type Code
- type ErrorResponse
- func NewAuthRequired(msg string, args ...any) *ErrorResponse
- func NewInternalError(msg string, args ...any) *ErrorResponse
- func NewInvalidRequest(msg string, args ...any) *ErrorResponse
- func Status(status int, msg string) *ErrorResponse
- func Wrap(err error, code Code, msg string) *ErrorResponse
- func Wrapf(err error, code Code, format string, args ...any) *ErrorResponse
- func (er *ErrorResponse) Cause() error
- func (er *ErrorResponse) Error() string
- func (er *ErrorResponse) Unwrap() error
- func (er *ErrorResponse) WithMsg(message string) *ErrorResponse
- func (er *ErrorResponse) WithMsgf(format string, args ...any) *ErrorResponse
- func (er *ErrorResponse) WithStatus(status int) *ErrorResponse
- func (er *ErrorResponse) Wrap(err error) *ErrorResponse
- type FromQuery
- type MetaContextKey
- type Method
- type Pipethrough
- type RPC
- type Request
- type RequestBuilder
- type RequestType
- type Server
- func (s *Server) AddHandler(method Method, handler http.Handler, ...)
- func (s *Server) AddHandlers(appliers ...)
- func (s *Server) AddRPCs(rpcs ...RPC)
- func (s *Server) Router() chi.Router
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) With(middleware ...func(http.Handler) http.Handler) *Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotImplemented = &ErrorResponse{ Code: MethodNotImplemented, Message: "Not Implemented", Status: http.StatusNotImplemented, }
Functions ¶
func NewMethod ¶
func NewMethod(nsid syntax.NSID, typ RequestType) *rpcMethod
func NewReqBuilder ¶
func NewReqBuilder() *requestBuilder
func WriteError ¶
func WriteInvalidRequest ¶
Types ¶
type Client ¶
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
func (*Client) Subscription ¶
type ClientOption ¶
type ClientOption func(*Client)
func WithAdminPassword ¶
func WithAdminPassword(pw string) ClientOption
func WithClient ¶
func WithClient(client *http.Client) ClientOption
func WithEnv ¶
func WithEnv() ClientOption
func WithHost ¶
func WithHost(host string) ClientOption
func WithInsecure ¶
func WithInsecure() ClientOption
func WithJwt ¶
func WithJwt(token string) ClientOption
func WithURL ¶
func WithURL(uri string) ClientOption
type Code ¶
type Code string
const ( Unknown Code = "Unknown" InvalidResponse Code = "InvalidResponse" Success Code = "Success" InvalidRequest Code = "InvalidRequest" AuthRequired Code = "AuthRequired" Forbidden Code = "Forbidden" XRPCNotSupported Code = "XRPCNotSupported" NotAcceptable Code = "NotAcceptable" PayloadTooLarge Code = "PayloadTooLarge" UnsupportedMediaType Code = "UnsupportedMediaType" RateLimitExceeded Code = "RateLimitExceeded" InternalServerError Code = "InternalServerError" MethodNotImplemented Code = "MethodNotImplemented" UpstreamFailure Code = "UpstreamFailure" NotEnoughResources Code = "NotEnoughResources" UpstreamTimeout Code = "UpstreamTimeout" )
func CodeFromStatus ¶
func (Code) MarshalText ¶
type ErrorResponse ¶
type ErrorResponse struct {
Code Code `json:"error"`
Message string `json:"message"`
// Status is for RPC handlers. Should not be send back to clients.
Status int `json:"-"`
// Inner is a private internal error associated with the response.
Inner error `json:"-"`
}
func NewAuthRequired ¶
func NewAuthRequired(msg string, args ...any) *ErrorResponse
func NewInternalError ¶
func NewInternalError(msg string, args ...any) *ErrorResponse
func NewInvalidRequest ¶
func NewInvalidRequest(msg string, args ...any) *ErrorResponse
func Status ¶
func Status(status int, msg string) *ErrorResponse
func (*ErrorResponse) Error ¶
func (er *ErrorResponse) Error() string
func (*ErrorResponse) Unwrap ¶
func (er *ErrorResponse) Unwrap() error
func (*ErrorResponse) WithMsg ¶
func (er *ErrorResponse) WithMsg(message string) *ErrorResponse
WithMsg sets the Message field.
func (*ErrorResponse) WithMsgf ¶
func (er *ErrorResponse) WithMsgf(format string, args ...any) *ErrorResponse
WithMsgf sets the Message field with an fmt.Sprintf format string.
func (*ErrorResponse) WithStatus ¶
func (er *ErrorResponse) WithStatus(status int) *ErrorResponse
WithStatus sets the Status field.
func (*ErrorResponse) Wrap ¶
func (er *ErrorResponse) Wrap(err error) *ErrorResponse
Wrap sets the Inner error field.
type MetaContextKey ¶
type MetaContextKey string
type Method ¶
type Method interface {
NSID() syntax.NSID
Type() RequestType
}
type Pipethrough ¶
func NewPipethrough ¶
func NewPipethrough(host string) *Pipethrough
func (*Pipethrough) ServeHTTP ¶
func (p *Pipethrough) ServeHTTP(w http.ResponseWriter, req *http.Request)
type Request ¶
type Request struct {
Type RequestType
ContentType string
NSID string
Params url.Values
Body io.Reader
}
func RequestFromHttp ¶
type RequestBuilder ¶
type RequestBuilder interface {
Build() (*http.Request, error)
Err() error
Type(RequestType) RequestBuilder
Insecure() RequestBuilder
Host(string) RequestBuilder
NSID(syntax.NSID) RequestBuilder
Query(url.Values) RequestBuilder
Body(io.Reader) RequestBuilder
}
type RequestType ¶
type RequestType int
const ( Query RequestType = iota + 1 Procedure Subscription )
func ComAtprotoRequestType ¶
func ComAtprotoRequestType(nsid string) RequestType
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) AddHandler ¶
func (*Server) AddHandlers ¶
Click to show internal directories.
Click to hide internal directories.