httprule

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeBinaryProto = "application/x-protobuf"
	ContentTypeJSON        = "application/json"
)

Variables

This section is empty.

Functions

func Collect

func Collect(md protoreflect.MethodDescriptor) (rules []*annotations.HttpRule)

Collect any annotations.Rule entries from a proto method.

func DecodeRequest

func DecodeRequest(rule *annotations.HttpRule, pathVars map[string]string, req *http.Request, target proto.Message) error

DecodeRequest parses a http.Request, using a HttpRule, into a target message.

func HTTPStatusFromCode added in v0.0.27

func HTTPStatusFromCode(code codes.Code) int

HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto

func MatchRequest

func MatchRequest(rule *annotations.HttpRule, req *http.Request) map[string]string

MatchRequest returns a non-nil map of extracted path vars if a http.Request matches a rule's request path and method.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server serves protobuf methods, annotated using httprule options, over HTTP.

func NewServer

func NewServer(files *registry.Files, handler grpc.StreamHandler) *Server

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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