Documentation ¶
Index ¶
- Variables
- func ErrInternal(err error) render.Renderer
- func ErrInvalidRequest(err error) render.Renderer
- func RenderOrErrInternal(w http.ResponseWriter, r *http.Request, d render.Renderer)
- type ErrResponse
- type JSONMarshaler
- func (jm *JSONMarshaler) ContentType() string
- func (jm *JSONMarshaler) Marshal(v interface{}) ([]byte, error)
- func (jm *JSONMarshaler) NewDecoder(r io.Reader) gwruntime.Decoder
- func (jm *JSONMarshaler) NewEncoder(w io.Writer) gwruntime.Encoder
- func (jm *JSONMarshaler) Unmarshal(data []byte, v interface{}) error
- type Server
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}
ErrNotFound is a pre-built not-found error
Functions ¶
func ErrInternal ¶
ErrInternal returns a generic server error to the user
func ErrInvalidRequest ¶
ErrInvalidRequest is used to indicate an error on user input (with wrapped error)
func RenderOrErrInternal ¶
RenderOrErrInternal will render whatever you pass it (assuming it has Renderer) or prints an internal error
Types ¶
type ErrResponse ¶
type ErrResponse struct { Err error `json:"-"` // low-level runtime error HTTPStatusCode int `json:"-"` // http response status code StatusText string `json:"status"` // user-level status message AppCode int64 `json:"code,omitempty"` // application-specific error code ErrorText string `json:"error,omitempty"` // application-level error message, for debugging }
ErrResponse is a generic struct for returning a standard error document
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
Render is the Renderer for ErrResponse struct
type JSONMarshaler ¶
type JSONMarshaler struct{}
func (*JSONMarshaler) ContentType ¶
func (jm *JSONMarshaler) ContentType() string
func (*JSONMarshaler) Marshal ¶
func (jm *JSONMarshaler) Marshal(v interface{}) ([]byte, error)
func (*JSONMarshaler) NewDecoder ¶
func (jm *JSONMarshaler) NewDecoder(r io.Reader) gwruntime.Decoder
func (*JSONMarshaler) NewEncoder ¶
func (jm *JSONMarshaler) NewEncoder(w io.Writer) gwruntime.Encoder
func (*JSONMarshaler) Unmarshal ¶
func (jm *JSONMarshaler) Unmarshal(data []byte, v interface{}) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the GRPC server
func (*Server) ErrInternalLog ¶
ErrInternalLog will log an error and return a generic server error to the user
func (*Server) GRPCServer ¶
GRPCServer will return the grpc server to allow functions to register themselves
func (*Server) GwReg ¶
func (s *Server) GwReg(gwrf gwRegFunc)
GwReg will save a gateway registration function for later when the server is started
func (*Server) ListenAndServe ¶
ListenAndServe will listen for requests
func (*Server) SetupRoutes ¶
func (s *Server) SetupRoutes()
SetupRoutes configures all the routes for this service