Documentation ¶
Overview ¶
Package httprpc provides goma httprpc implementation.
Index ¶
- func AdmissionControl(ac AdmissionController, h http.Handler) http.Handler
- func AuthHandler(a AuthChecker, h http.Handler) http.Handler
- func Call(ctx context.Context, client *http.Client, url string, req proto.Message, ...) error
- func Handler(name string, req, resp proto.Message, ...) http.Handler
- func RemoteAddr(req *http.Request) string
- func StreamHandler(name string, ...) http.Handler
- func Trace(handler http.Handler, labels map[string]string) http.Handler
- type AdmissionController
- type Auth
- type AuthChecker
- type Client
- type HandlerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdmissionControl ¶
func AdmissionControl(ac AdmissionController, h http.Handler) http.Handler
AdmissionControl adds admission controller to h.
func AuthHandler ¶
func AuthHandler(a AuthChecker, h http.Handler) http.Handler
AuthHandler converts given http.Handler to access controlled HTTP handler using AuthChecker. Alternatives: WithAuth handler option if it requires retry with Unauthenticated error.
func Call ¶
func Call(ctx context.Context, client *http.Client, url string, req proto.Message, resp proto.Message) error
Call calls remote services over http.
func Handler ¶
func Handler(name string, req, resp proto.Message, h func(context.Context, proto.Message) (proto.Message, error), opts ...HandlerOption) http.Handler
Handler returns http.Handler to serve http rpc handler.
func RemoteAddr ¶
RemoteAddr returns http's remote (client) addr. https://cloud.google.com/compute/docs/load-balancing/http/#components
func StreamHandler ¶
func StreamHandler(name string, h func(ctx context.Context, w http.ResponseWriter, req *http.Request) error, opts ...HandlerOption) http.Handler
Handler returns http.Handler to serve http stream.
Types ¶
type AdmissionController ¶
AdmissionController checks incoming request.
type AuthChecker ¶
type AuthChecker interface { // Check represents the function to check HTTP access. // If the access is granted, it returns non-nil enduser.EndUser instance. Check(context.Context, *http.Request) (*enduser.EndUser, error) }
AuthChecker represents an interface to checks HTTP access.
type Client ¶
type Client struct { *http.Client // endpoint URL. URL string // ContentEncoding of the request. "identity", "gzip" or "deflate". // "deflate" uses "deflate" compressed data (RFC1951) without // zlib header, different from RFC7230 says, for histrical reason. // default is "deflate" for backward compatibility. // TODO: change default to gzip? ContentEncoding string }
Client is httprpc client.
type HandlerOption ¶
type HandlerOption func(*option)
HandlerOption sets option for handler.
func Timeout ¶
func Timeout(d time.Duration) HandlerOption
Timeout sets timeout to the handler. Default is 1 second.
func WithAPIKey ¶
func WithAPIKey(apiKey string) HandlerOption
WithAPIKey sets api key in outgoing context.
func WithCluster ¶
func WithCluster(c string) HandlerOption
WithCluster sets cluster name to the handler for logging/monitoring etc.
func WithNamespace ¶
func WithNamespace(ns string) HandlerOption
WithNamespace sets cluster namespace to the handler for logging/monitoring etc.
func WithRetry ¶
func WithRetry(retry rpc.Retry) HandlerOption
WithRetry sets retry config to the handler.
Directories ¶
Path | Synopsis |
---|---|
Package authdb implements authdb service for goma httprpc.
|
Package authdb implements authdb service for goma httprpc. |
Package bytestream implements bytestream for goma http.
|
Package bytestream implements bytestream for goma http. |
Package exec implements exec service for goma httprpc.
|
Package exec implements exec service for goma httprpc. |
Package execlog implements log service for goma httprpc.
|
Package execlog implements log service for goma httprpc. |
Package file implements file service for goma httprpc.
|
Package file implements file service for goma httprpc. |
Package settings implements settings service for goma httprpc.
|
Package settings implements settings service for goma httprpc. |