Documentation ¶
Overview ¶
Package httpservice provides an HTTP service that accepts a twicmd.Service and provides it over HTTP as a Protobuf REST API.
API Specification ¶
For each service, the following endpoints are provided:
- GET / - returns the service description in Protobuf format.
- POST /execute - accepts a command in Protobuf format and returns the result message body in Protobuf format.
Index ¶
- type Client
- func (s *Client) ApplyConfigurationValues(ctx context.Context, req *twicmdcfgpb.ApplyRequest) (*twicmdcfgpb.ApplyResponse, error)
- func (s *Client) ConfigurationValues(ctx context.Context, req *twicmdcfgpb.OptionsRequest) (*twicmdcfgpb.OptionsResponse, error)
- func (s *Client) Execute(ctx context.Context, req *twicmdproto.ExecuteRequest) (*twicmdproto.ExecuteResponse, error)
- func (s *Client) Name() string
- func (s *Client) Service(ctx context.Context) (*twicmdproto.Service, error)
- func (s *Client) Start(ctx context.Context) error
- func (s *Client) SubscribeMessages(ch chan<- *twismsproto.Message, filters *twismsproto.MessageFilters)
- func (s *Client) UnsubscribeMessages(ch chan<- *twismsproto.Message)
- type ClientConfig
- type Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps an HTTP API and implements twicmd.Service.
func (*Client) ApplyConfigurationValues ¶
func (s *Client) ApplyConfigurationValues(ctx context.Context, req *twicmdcfgpb.ApplyRequest) (*twicmdcfgpb.ApplyResponse, error)
func (*Client) ConfigurationValues ¶
func (s *Client) ConfigurationValues(ctx context.Context, req *twicmdcfgpb.OptionsRequest) (*twicmdcfgpb.OptionsResponse, error)
func (*Client) Execute ¶
func (s *Client) Execute(ctx context.Context, req *twicmdproto.ExecuteRequest) (*twicmdproto.ExecuteResponse, error)
Execute implements twicmd.Service.
func (*Client) Service ¶
Service implements twicmd.Service.
func (*Client) Start ¶
Start implements twid.Starter.
func (*Client) SubscribeMessages ¶
func (s *Client) SubscribeMessages(ch chan<- *twismsproto.Message, filters *twismsproto.MessageFilters)
SubscribeMessages implements twisms.MessageSubscriber.
func (*Client) UnsubscribeMessages ¶
func (s *Client) UnsubscribeMessages(ch chan<- *twismsproto.Message)
UnsubscribeMessages implements twisms.MessageSubscriber.
type ClientConfig ¶
type ClientConfig struct { // Name is the name of the service. Name string `json:"name"` // BaseURL is the base BaseURL of the HTTP service. BaseURL string `json:"base_url"` }
ClientConfig is the expected configuration for an HTTP service.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler wraps a twicmd.Service and turns it into an HTTP server.
func NewHandler ¶
NewHandler creates a new HTTP server with the given service.
func (*Handler) ServeHTTP ¶
func (s *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.