Documentation ¶
Overview ¶
Package rpc provides simple RPC style APIs with generated clients & servers.
Index ¶
- func BadRequest(message string) error
- func Error(status int, kind, message string) error
- func Invalid(message string) error
- func NewRequestContext(ctx context.Context, v *http.Request) context.Context
- func ReadRequest(r *http.Request, value interface{}) error
- func RequestFromContext(ctx context.Context) (*http.Request, bool)
- func WriteError(w http.ResponseWriter, err error)
- func WriteHealth(w http.ResponseWriter, s interface{})
- func WriteResponse(w http.ResponseWriter, value interface{})
- type HealthChecker
- type ServerError
- type StatusProvider
- type TypeProvider
- type ValidationError
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRequestContext ¶
NewRequestContext returns a new context with ctx.
func ReadRequest ¶
ReadRequest parses application/json request bodies into value, or returns an error.
func RequestFromContext ¶
RequestFromContext returns ctx from context.
func WriteError ¶
func WriteError(w http.ResponseWriter, err error)
WriteError writes an error.
If err is a StatusProvider the status code provided is used, otherwise it defaults to StatusInternalServerError.
If err is a TypeProvider the type provided is used, otherwise it defaults to "internal".
The message in the response uses the Error() implementation.
func WriteHealth ¶
func WriteHealth(w http.ResponseWriter, s interface{})
WriteHealth responds with 200 OK or invokes the Health() method on the server if it implements the HealthChecker interface.
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, value interface{})
WriteResponse writes a JSON response, or 204 if the value is nil to indicate there is no content.
Types ¶
type HealthChecker ¶
type HealthChecker interface {
Health() error
}
HealthChecker is the interface used for servers providing a health check.
type ServerError ¶
type ServerError struct {
// contains filtered or unexported fields
}
ServerError is a server error which implements StatusProvider and TypeProvider.
type StatusProvider ¶
type StatusProvider interface {
StatusCode() int
}
StatusProvider is the interface used for providing an HTTP status code.
type TypeProvider ¶
type TypeProvider interface {
Type() string
}
TypeProvider is the interface used for providing an error type.
type ValidationError ¶
ValidationError is a field validation error.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
generators
|
|
internal
|
|
Package schema provides the Apex RPC schema.
|
Package schema provides the Apex RPC schema. |