server: Index | Files | Directories

package httprpc

import ""

Package httprpc provides goma httprpc implementation.


Package Files

admission.go auth.go client.go doc.go server.go trace.go

func AdmissionControl Uses

func AdmissionControl(ac AdmissionController, h http.Handler) http.Handler

AdmissionControl adds admission controller to h.

func AuthHandler Uses

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 Uses

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 Uses

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 Uses

func RemoteAddr(req *http.Request) string

RemoteAddr returns http's remote (client) addr.

func StreamHandler Uses

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.

func Trace Uses

func Trace(handler http.Handler, labels map[string]string) http.Handler

Trace adds labels to trace span for requested path. It would be used as top handler for incoming request under ochttp.Handler.

type AdmissionController Uses

type AdmissionController interface {
    Admit(*http.Request) error

AdmissionController checks incoming request.

type Auth Uses

type Auth interface {
    Auth(context.Context, *http.Request) (context.Context, error)

Auth authenticates the request.

type AuthChecker Uses

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 Uses

type Client struct {

    // 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.

func (*Client) Call Uses

func (c *Client) Call(ctx context.Context, req proto.Message, resp proto.Message) error

Call calls remote services over http.

type HandlerOption Uses

type HandlerOption func(*option)

HandlerOption sets option for handler.

func Timeout Uses

func Timeout(d time.Duration) HandlerOption

Timeout sets timeout to the handler. Default is 1 second.

func WithAPIKey Uses

func WithAPIKey(apiKey string) HandlerOption

WithAPIKey sets api key in outgoing context.

func WithAuth Uses

func WithAuth(a Auth) HandlerOption

WithAuth sets auth to the handler.

func WithCluster Uses

func WithCluster(c string) HandlerOption

WithCluster sets cluster name to the handler for logging/monitoring etc.

func WithNamespace Uses

func WithNamespace(ns string) HandlerOption

WithNamespace sets cluster namespace to the handler for logging/monitoring etc.

func WithRetry Uses

func WithRetry(retry rpc.Retry) HandlerOption

WithRetry sets retry config to the handler.


authdbPackage authdb implements authdb service for goma httprpc.
bytestreamPackage bytestream implements bytestream for goma http.
execPackage exec implements exec service for goma httprpc.
execlogPackage execlog implements log service for goma httprpc.
filePackage file implements file service for goma httprpc.
settingsPackage settings implements settings service for goma httprpc.

Package httprpc imports 19 packages (graph) and is imported by 12 packages. Updated 2020-10-27. Refresh now. Tools for package owners.