cerpc

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: BSD-2-Clause Imports: 25 Imported by: 0

Documentation

Overview

Package cerpc handles RPCs over HTTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHeader

func AddHeader(ctx context.Context, key, value string) bool

AddHeader sets a header to be returned by the current cerpc HTTP request.

func AttachRequest added in v0.1.0

func AttachRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) context.Context

AttachRequest creates a new context that has the given ResponseWriter and Request attached. It allows GetCookie and AddHeader on the returned context. Most users don't need this function because it's automatically attached when using the cerpc generated http handler.

func GetCookie

func GetCookie(ctx context.Context, key string) (*http.Cookie, error)

GetCookie gets a cookie from the current request. The current request is determined from the context.

func GetHeader added in v0.2.0

func GetHeader(ctx context.Context, key string) string

GetHeader gets the first value of the header associated with key from the current request. The current request is determined from the context.

func GetRequest added in v0.3.0

func GetRequest(ctx context.Context) *http.Request

GetRequest gets the current request from the context.

func InternalDecodeRequest

func InternalDecodeRequest(w http.ResponseWriter, r *http.Request, inMsg proto.Message) bool

func InternalDoClientRequest added in v0.2.0

func InternalDoClientRequest(ctx context.Context, url string, req, resp proto.Message, options []ClientOption) error

func InternalDoClientStream added in v0.2.0

func InternalDoClientStream(ctx context.Context, urlString string, options []ClientOption) (grpc.ClientStream, error)

func InternalHandleRequest

func InternalHandleRequest(w http.ResponseWriter, r *http.Request, inMsg proto.Message, handler func(ctx context.Context) (proto.Message, error))

func InternalRejectUnknownRPC

func InternalRejectUnknownRPC(w http.ResponseWriter, name string)

func InternalUpgrade

func InternalUpgrade(w http.ResponseWriter, r *http.Request, handler func(grpc.ServerStream) error)

func WriteError

func WriteError(w http.ResponseWriter, err error)

Types

type ClientOption added in v0.2.0

type ClientOption func(*clientOptions)

ClientOption allows you to change the default settings of the generated New*CeRPCClient().

func WithHTTPClient added in v0.2.0

func WithHTTPClient(h *http.Client) ClientOption

WithHTTPClient lets the Client use this http.Client rather than http.DefaultClient.

func WithHTTPHeaders added in v0.2.0

func WithHTTPHeaders(h http.Header) ClientOption

WithHTTPHeaders lets the Client send these extra headers.

func WithWebsocketDialer added in v0.2.0

func WithWebsocketDialer(w websocket.Dialer) ClientOption

WithWebsocketDialer lets the Client use this websocket.Dialer rather than the default.

type Service

type Service interface {
	http.Handler
	Name() string
}

Jump to

Keyboard shortcuts

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