Documentation
¶
Index ¶
- func JSON(c echo.Context, status int, i interface{}) error
- func Msgpack(c echo.Context, status int, i interface{}) error
- func NewHandler(s *Server) http.Handler
- type Channel
- type ChannelUser
- type Emailer
- type Encrypted
- type ErrHTTP
- type Fire
- type LogLevel
- type Logger
- type Redis
- type Server
- func (s *Server) AddRoutes(e *echo.Echo)
- func (s *Server) ErrBadRequest(c echo.Context, err error) error
- func (s *Server) ErrConflict(c echo.Context, err error) error
- func (s *Server) ErrEntityTooLarge(c echo.Context, err error) error
- func (s *Server) ErrForbidden(c echo.Context, err error) error
- func (s *Server) ErrNotFound(c echo.Context, err error) error
- func (s *Server) ErrResponse(c echo.Context, err error) error
- func (s *Server) ErrTooManyRequests(c echo.Context, err error) error
- func (s *Server) ErrorHandler(err error, c echo.Context)
- func (s *Server) GenerateToken() string
- func (s *Server) SetClock(clock tsutil.Clock)
- func (s *Server) SetEmailer(emailer Emailer)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler returns http.Handler for Server.
Types ¶
type Channel ¶
type Channel struct {
ID keys.ID `json:"id" msgpack:"id"`
Index int64 `json:"idx,omitempty"`
Timestamp int64 `json:"ts,omitempty"`
Token string `json:"token,omitempty"`
Usage int64 `json:"usage,omitempty"`
Deleted bool `json:"del,omitempty"`
CreatedBy keys.ID `json:"createdBy,omitempty"`
Info Encrypted `json:"info,omitempty"`
Team keys.ID `json:"team,omitempty"`
TeamKey Encrypted `json:"teamKey,omitempty"`
}
type ChannelUser ¶
type ErrHTTP ¶
type ErrHTTP struct {
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Err error `json:"-"`
}
ErrHTTP ...
type Logger ¶
type Logger interface {
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Errorf(format string, args ...interface{})
}
Logger compatible with GCP.
type Redis ¶
type Redis interface {
// Get returns value at key.
Get(ctx context.Context, k string) (string, error)
// Put puts a value at key.
Set(ctx context.Context, k string, v string) error
// Delete key.
Delete(ctx context.Context, k string) error
// Expire key.
Expire(ctx context.Context, k string, dt time.Duration) error
// Increment value at key.
Increment(ctx context.Context, k string) (int64, error)
// Publish data to key.
Publish(ctx context.Context, k string, b []byte) error
}
Redis defines interface for a distributed key value store. Used to prevent nonce re-use for authenticated requests.
func NewRedisTest ¶
NewRedisTest returns Redis for testing.
type Server ¶
type Server struct {
// URL (base) of form http(s)://host:port with no trailing slash to help
// authorization checks in testing where the host is ambiguous.
URL string
// contains filtered or unexported fields
}
Server ...
func New ¶
func New(fi Fire, rds Redis, config api.Config, client http.Client, clock tsutil.Clock, logger Logger) *Server
New creates a Server.
func (*Server) ErrBadRequest ¶
ErrBadRequest response.
func (*Server) ErrConflict ¶
ErrConflict response.
func (*Server) ErrEntityTooLarge ¶
ErrEntityTooLarge response.
func (*Server) ErrForbidden ¶
ErrForbidden response.
func (*Server) ErrNotFound ¶
ErrNotFound response.
func (*Server) ErrResponse ¶
ErrResponse is a generate error response. All errors come through here.
func (*Server) ErrTooManyRequests ¶
ErrTooManyRequests response.
func (*Server) ErrorHandler ¶
ErrorHandler returns error handler that returns in the format: {"error": {"message": "error message", status: 500}}".
func (*Server) GenerateToken ¶
Click to show internal directories.
Click to hide internal directories.