Documentation ¶
Index ¶
- Constants
- func ErrorResponseJSON(c echo.Context, err error, details interface{}) error
- func ListenAndServeTLSRedirect(domain string) error
- func MessageFromErr(err error) string
- func StatusCodeFromErr(err error) int
- func SuccessResponseJSON(c echo.Context, httpCode int, data interface{}) error
- type ErrorAPI
- type ServerAPI
- func (s *ServerAPI) AuthLoginHandler(c echo.Context) error
- func (s *ServerAPI) AuthLogoutHandler(c echo.Context) error
- func (s *ServerAPI) AuthRefreshHandler(c echo.Context) error
- func (s *ServerAPI) AuthRegisterHandler(c echo.Context) error
- func (s *ServerAPI) Close() error
- func (s *ServerAPI) ContractCallHandler(c echo.Context) error
- func (s *ServerAPI) ContractCallRevHandler(c echo.Context) error
- func (s *ServerAPI) ContractCreateHandler(c echo.Context) error
- func (s *ServerAPI) ContractHandler(c echo.Context) error
- func (s *ServerAPI) ContractMakeRevisionHandler(c echo.Context) error
- func (s *ServerAPI) ContractUpdateHandler(c echo.Context) error
- func (s *ServerAPI) HTTPContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (s *ServerAPI) JWTVerifyMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (s *ServerAPI) Open() (err error)
- func (s *ServerAPI) Port() int
- func (s *ServerAPI) RecoverPanicMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (s *ServerAPI) Scheme() string
- func (s *ServerAPI) URL() string
- func (s *ServerAPI) UseTLS() bool
- func (s *ServerAPI) UserHandler(c echo.Context) error
- func (s *ServerAPI) UserUpdateHandler(c echo.Context) error
- func (s *ServerAPI) VmStatsHandler(c echo.Context) error
Constants ¶
const (
GenericErrorMessage = "An error occurred"
)
const ShutdownTimeout = 1 * time.Second
ShutdownTimeout is the time given for outstanding requests to finish before shutdown.
Variables ¶
This section is empty.
Functions ¶
func ErrorResponseJSON ¶
ErrorResponseJSON returns an HTTP error response with JSON content.
func ListenAndServeTLSRedirect ¶
ListenAndServeTLSRedirect runs an HTTP server on port 80 to redirect users to the TLS-enabled port 443 server.
func MessageFromErr ¶
MessageFromErr returns the message for the given app error. EINTERNAL & EUNKNOWN message is obscured by HTTP response.
func StatusCodeFromErr ¶
StatusCodeFromErr returns the HTTP status code for the given app error.
func SuccessResponseJSON ¶
SuccessResponseJSON returns a JSON response with the given status code and data.
Types ¶
type ErrorAPI ¶
type ErrorAPI struct { Code string `json:"code"` Message string `json:"message"` Details interface{} `json:"details"` }
ErrorAPI represents an error returned by the API.
func NewErrorAPI ¶
NewErrorAPI returns an ErrorAPI instance.
type ServerAPI ¶
type ServerAPI struct { // Addr Bind address for the server. Addr string // Domain name to use for the server. // If specified, server is run on TLS using acme/autocert. Domain string // JWTSecret is the secret used to sign JWT tokens. JWTSecret string // service handler ServiceHandler *handler.ServiceHandler // loggin service used by HTTP Server. LogService log.Logger // contains filtered or unexported fields }
ServerAPI is the main server for the API
func (*ServerAPI) AuthLoginHandler ¶
AuthLoginHandler handles the login request.
func (*ServerAPI) AuthLogoutHandler ¶
AuthLogoutHandler handles the logout request.
func (*ServerAPI) AuthRefreshHandler ¶
AuthRefreshHandler handles the refresh request.
func (*ServerAPI) AuthRegisterHandler ¶
AuthRegisterHandler handles the register request.
func (*ServerAPI) ContractCallHandler ¶ added in v0.0.7
ContractCallHandler is the handler for the /contract/:id/call API.
func (*ServerAPI) ContractCallRevHandler ¶ added in v0.0.7
ContractCallRevHandler is the handler for the /contract/:id/call/:rev API.
func (*ServerAPI) ContractCreateHandler ¶ added in v0.0.7
ContractCreateHandler is the handler for the /contract create API.
func (*ServerAPI) ContractHandler ¶ added in v0.0.7
ContractHandler is the handler for the /contract/:id search API.
func (*ServerAPI) ContractMakeRevisionHandler ¶ added in v0.0.7
ContractMakeRevisionHandler is the handler for the /contract/:id/revision create API.
func (*ServerAPI) ContractUpdateHandler ¶ added in v0.0.7
ContractUpdateHandler is the handler for the /contract/:id update API.
func (*ServerAPI) HTTPContextMiddleware ¶
func (s *ServerAPI) HTTPContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc
HTTPContextMiddleware is the middleware for setting the HTTP tag in the context.
func (*ServerAPI) JWTVerifyMiddleware ¶
func (s *ServerAPI) JWTVerifyMiddleware(next echo.HandlerFunc) echo.HandlerFunc
JWTVerifyMiddleware is the middleware for validating JWT tokens. It is used for all routes that require authentication. Once the token is successfully parsed, checks if user exists with the auth stored in the claims.
func (*ServerAPI) Port ¶
Port returns the TCP port for the running server. This is useful in tests where we allocate a random port by using ":0".
func (*ServerAPI) RecoverPanicMiddleware ¶
func (s *ServerAPI) RecoverPanicMiddleware(next echo.HandlerFunc) echo.HandlerFunc
RecoverPanicMiddleware is the middleware for handling panics.
func (*ServerAPI) URL ¶
URL returns the URL for the server. This is useful in tests where we allocate a random port by using ":0".
func (*ServerAPI) UserHandler ¶
UserHandler is the handler for the /user API.
func (*ServerAPI) UserUpdateHandler ¶
UserUpdateHandler is the handler for the /user update API.