Documentation ¶
Index ¶
- Constants
- Variables
- func GetMarshaler(s server.HTTPServer, req *http.Request) (inbound, outbound marshaler.Marshaler)
- func GetMarshalerMap() map[string]marshaler.Marshaler
- func HandleGRPCResponse(w http.ResponseWriter, r *http.Request, headers map[string]string) (bool, error)
- func NewIncomingContext(ctx context.Context, headers map[string]string) context.Context
- func NewServer(name string, runtime runtime.Runtime, options *server.HTTPServerOptions) server.HTTPServer
- func WithExcludeGlobalMiddleware(regexp string) server.HTTPServerOption
- func WithMiddleware(middleware server.KindMiddleware) server.HTTPServerOption
- type Config
- type HandleOption
- type HandleOptions
- type Handler
- type Middlewares
- type Wrapper
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: defaultMarshalOptions,
UnmarshalOptions: defaultUnmarshalOptions,
}
)
Functions ¶
func GetMarshaler ¶
func GetMarshalerMap ¶
func HandleGRPCResponse ¶
func NewIncomingContext ¶
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 Middlewares ¶
type Middlewares struct {
// contains filtered or unexported fields
}
func (*Middlewares) Add ¶
func (m *Middlewares) Add(h server.HttpServerMiddleware)
func (*Middlewares) AddConstructor ¶
func (m *Middlewares) AddConstructor(h interface{})
func (*Middlewares) SetGlobal ¶
func (m *Middlewares) SetGlobal(middlewares ...server.KindMiddleware)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.