Documentation ¶
Index ¶
- Variables
- func GetHandlerNameFromContext(ctx context.Context) string
- func HandleError(w http.ResponseWriter, err error)
- func Register[Input any, Output any](mux *http.ServeMux, httpMethod HTTPMethod, path string, ...)
- func RegisterDocsEndpoint(mux *http.ServeMux)
- func RegisterMiddleware(middlewware ...Middleware)
- func SetHandlerNameInContext(ctx context.Context, handlerName string) context.Context
- type HTTPMethod
- type Middleware
- type RpcEndpoint
- type RpcError
- type RpcHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var InternalServerError = RpcError{HTTPCode: 500, Message: "Internal Server Error"}
Functions ¶
func HandleError ¶
func HandleError(w http.ResponseWriter, err error)
func Register ¶
func Register[Input any, Output any](mux *http.ServeMux, httpMethod HTTPMethod, path string, h RpcHandler[Input, Output], rpcMiddleware ...Middleware)
Register registers a new RPC handler to the given mux. handlers are applied in the order they are registered. Handlers regiestered with RegisterMiddleware are applied first.
func RegisterDocsEndpoint ¶
func RegisterMiddleware ¶
func RegisterMiddleware(middlewware ...Middleware)
RegisterMiddleware registers a middleware that is used for all RPCs that are registed. Use the handlers argument in Register to apply RPC specific middleware in addition to the default middleware.
Handlers are applied in the order they are registered.
Types ¶
type HTTPMethod ¶
type HTTPMethod string
const ( GET HTTPMethod = http.MethodGet POST HTTPMethod = http.MethodPost )
type RpcEndpoint ¶
type RpcEndpoint struct { Path string `json:"path"` HTTPMethod HTTPMethod `json:"httpMethod"` InputType string `json:"inputType"` Input interface{} `json:"input"` OutputType string `json:"outputType"` Output interface{} `json:"output"` }
Docs
type RpcError ¶
func NewBadRequestError ¶
func (RpcError) IsClientError ¶
func (RpcError) IsServerError ¶
Click to show internal directories.
Click to hide internal directories.