httprpc

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2019 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package httprpc provides goma httprpc implementation.

Index

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

func RemoteAddr(req *http.Request) string

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.

func Trace

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.

Types

type AdmissionController

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

AdmissionController checks incoming request.

type Auth

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

Auth authenticates the 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.

func (*Client) Call

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

Call calls remote services over http.

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 WithAuth

func WithAuth(a Auth) HandlerOption

WithAuth sets auth to the handler.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL