Documentation ¶
Index ¶
- Constants
- Variables
- func AcceptTypeFromHeaders(ctx context.Context) string
- func ContentTypeFromHeaders(ctx context.Context) string
- func DefaultEncoder(req *http.Request, r interface{}) error
- func DefaultWSUpgrader(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*websocket.Conn, error)
- func GrpcErrorToHTTP(err error, defaultStatus int, defaultMessage string) (int, string)
- func NewHTTPHandler(config Config) handlers.Handler
- type Config
Constants ¶
View Source
const ( ContentTypeJSON = "application/json" ContentTypeProto = "application/octet-stream" )
View Source
const (
//IgnoreNR is the option flag to ignore newrelic for this method
IgnoreNR = "IGNORE_NR"
)
Variables ¶
View Source
var ( //ContentTypeMap is the mapping of content-type with marshaling type ContentTypeMap = map[string]string{ ContentTypeJSON: modifiers.JSON, "application/jsonpb": modifiers.JSONPB, "application/x-jsonpb": modifiers.JSONPB, "application/protobuf": modifiers.ProtoBuf, "application/proto": modifiers.ProtoBuf, "application/x-proto": modifiers.ProtoBuf, "application/vnd.google.protobuf": modifiers.ProtoBuf, ContentTypeProto: modifiers.ProtoBuf, } // DefaultHTTPResponseHeaders are response headers that are whitelisted by default DefaultHTTPResponseHeaders = []string{ "Content-Type", } )
Functions ¶
func AcceptTypeFromHeaders ¶
AcceptTypeFromHeaders searches for a mathing accept type
func ContentTypeFromHeaders ¶
ContentTypeFromHeaders searches for a matching content type
func DefaultEncoder ¶
DefaultEncoder encodes a HTTP request if none are registered. This encoder populates the proto message with URL route variables or fields from a JSON body if either are available.
func DefaultWSUpgrader ¶
func DefaultWSUpgrader(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*websocket.Conn, error)
DefaultWSUpgrader upgrades a websocket if none are registered.
func GrpcErrorToHTTP ¶
GrpcErrorToHTTP converts gRPC error code into HTTP response status code. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func NewHTTPHandler ¶
NewHTTPHandler creates a new HTTP handler
Types ¶
type Config ¶
type Config struct { handlers.CommonConfig EnableProtoURL bool }
Config is the configuration for HTTP Handler
Source Files ¶
Click to show internal directories.
Click to hide internal directories.