Documentation ¶
Overview ¶
Package cerpc handles RPCs over HTTP.
Index ¶
- func AddHeader(ctx context.Context, key, value string) bool
- func AttachRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) context.Context
- func GetCookie(ctx context.Context, key string) (*http.Cookie, error)
- func GetHeader(ctx context.Context, key string) string
- func GetRequest(ctx context.Context) *http.Request
- func InternalDecodeRequest(w http.ResponseWriter, r *http.Request, inMsg proto.Message) bool
- func InternalDoClientRequest(ctx context.Context, url string, req, resp proto.Message, ...) error
- func InternalDoClientStream(ctx context.Context, urlString string, options []ClientOption) (grpc.ClientStream, error)
- func InternalHandleRequest(w http.ResponseWriter, r *http.Request, inMsg proto.Message, ...)
- func InternalRejectUnknownRPC(w http.ResponseWriter, name string)
- func InternalUpgrade(w http.ResponseWriter, r *http.Request, handler func(grpc.ServerStream) error)
- func WriteError(w http.ResponseWriter, err error)
- type ClientOption
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachRequest ¶ added in v0.1.0
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 ¶
GetCookie gets a cookie from the current request. The current request is determined from the context.
func GetHeader ¶ added in v0.2.0
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
GetRequest gets the current request from the context.
func InternalDecodeRequest ¶
func InternalDoClientRequest ¶ added in v0.2.0
func InternalDoClientStream ¶ added in v0.2.0
func InternalDoClientStream(ctx context.Context, urlString string, options []ClientOption) (grpc.ClientStream, error)
func InternalHandleRequest ¶
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.