http

package
v0.0.0-...-692e367 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeForm = "application/x-www-form-urlencoded"
	ContentTypeJSON = "application/json"
)
View Source
const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	MethodOptions = "OPTIONS"
	MethodTrace   = "TRACE"
)
View Source
const MiddlewareNotFoundError string = "Can not apply middleware router: %s Can not find global server middleware: %s. To " +
	"register middleware, please add Server().HTTP().SetMiddleware(\"%s\", http.Handler) to runtime."

Variables

View Source
var (
	NewReader                          = converter.NewReader
	ParseRequestQueryParametersToProto = converter.ParseRequestQueryParametersToProto
	ParseRequestUrlParametersToProto   = converter.ParseRequestUrlParametersToProto
	SetRawBodyToProto                  = converter.SetRawBodyToProto
	PrepareHeaderFromRequest           = converter.PrepareHeaderFromRequest
)
View Source
var (
	DefaultMarshaler = &jsonpb.JSONPb{
		MarshalOptions: protojson.MarshalOptions{
			EmitUnpopulated: true,
		},
		UnmarshalOptions: protojson.UnmarshalOptions{
			DiscardUnknown: true,
		},
	}
)

Functions

func GetMarshaler

func GetMarshaler(s server.HTTPServer, req *http.Request) (inbound, outbound marshaler.Marshaler)

func GetMarshalerMap

func GetMarshalerMap() map[string]marshaler.Marshaler

func HandleGRPCResponse

func HandleGRPCResponse(w http.ResponseWriter, r *http.Request, headers map[string]string) (bool, error)

func NewIncomingContext

func NewIncomingContext(ctx context.Context, headers map[string]string) context.Context

func NewServer

func NewServer(name string, runtime runtime.Runtime, options *server.HTTPServerOptions) server.HTTPServer

func WithExcludeGlobalMiddleware

func WithExcludeGlobalMiddleware(regexp string) server.HTTPServerOption

func WithMiddleware

func WithMiddleware(middleware server.KindMiddleware) server.HTTPServerOption

Types

type Config

type Config struct {
	Id string

	Host string `env:"SERVER_LISTEN" envDefault:"0.0.0.0" comment:"Set HTTP server listen host"`
	Port int    `env:"SERVER_PORT" envDefault:"8080" comment:"Set HTTP server listen port"`

	Prefix string

	EnableCORS bool `env:"SERVER_CORS_ENABLED" envDefault:"false" comment:"Enable Cross-Origin Resource Sharing header"`
	IsDisable  bool

	TLSConfig *tls.Config
}

type HandleOption

type HandleOption func(*HandleOptions)

type HandleOptions

type HandleOptions struct {
	Middlewares server.HttpServerMiddleware
}

type Handler

type Handler func(w http.ResponseWriter, r *http.Request) error

type Middlewares

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

func (*Middlewares) Add

func (*Middlewares) AddConstructor

func (m *Middlewares) AddConstructor(h interface{})

func (*Middlewares) SetGlobal

func (m *Middlewares) SetGlobal(middlewares ...server.KindMiddleware)

type Wrapper

type Wrapper func(h http.Handler) http.Handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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