Documentation
¶
Index ¶
Constants ¶
const (
CtxRequestID contextKey = iota
)
Context value parameters
const (
HeaderRequestID = "X-Request-ID"
)
Header constants
Variables ¶
var ( ErrMissingBody = errors.New("missing body") ErrInvalidRequest = errors.New("invalid request") ErrInvalidRequestBody = errors.New("invalid request body") ErrBodyTooLarge = errors.New("body too large") )
Errors
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*TySugServer)
Option is a handy type used for configuration purposes
func WithDefaultHeaders ¶ added in v0.1.0
WithDefaultHeaders sets the default headers to be used when writing a response.
func WithGzipHandler ¶ added in v0.0.2
func WithGzipHandler() Option
WithGzipHandler adds a gzip handler to the server's handlers
func WithInputLimitValidator ¶ added in v0.0.2
WithInputLimitValidator specifies a max input-value limit validator
func WithLogger ¶
WithLogger sets the logger to be used when encountering http-related errors. Errors are written to the standard error output in most cases. Printing on the standard output is reserved to extreme case where writing on stderr failed.
type ServiceRegistry ¶ added in v0.0.2
type ServiceRegistry struct {
// contains filtered or unexported fields
}
ServiceRegistry holds (opinionated) service objects for handling specific requests
func NewServiceRegistry ¶ added in v0.0.2
func NewServiceRegistry() ServiceRegistry
NewServiceRegistry creates a new registry
func (ServiceRegistry) GetServiceForList ¶ added in v0.0.2
func (rlh ServiceRegistry) GetServiceForList(name string) Service
GetServiceForList returns a service able to handle a specific list
func (ServiceRegistry) HasServiceForList ¶ added in v0.0.2
func (rlh ServiceRegistry) HasServiceForList(name string) bool
HasServiceForList returns true only if a service has been registered for a certain list
func (*ServiceRegistry) Register ¶ added in v0.0.2
func (rlh *ServiceRegistry) Register(listName string, svc Service) *ServiceRegistry
Register registers a new service with a list of references
type TySugServer ¶
TySugServer the HTTP server
func NewHTTP ¶
func NewHTTP(sr ServiceRegistry, mux *http.ServeMux, options ...Option) TySugServer
NewHTTP constructs a new TySugServer
func (*TySugServer) ListenOnAndServe ¶
func (tss *TySugServer) ListenOnAndServe(addr string) error
ListenOnAndServe allows to set the host:port URL late. It calls ListenAndServe()