Documentation
¶
Index ¶
- Constants
- func GetAuthnInfo(ctx context.Context) any
- func NewAuthnMiddleware(authnFn func(context.Context, *http.Request) (any, error), ...) httpo.HttpMiddleware
- func NewConnectCorsOptions(options cors.Options) cors.Options
- func NewCorsHandler(config corso.Config) httpo.HttpMiddleware
- func RegisterGrpcHealth(server *connect.Server)
- func RegisterGrpcReflect(server *connect.Server)
- func SetAuthnInfo(ctx context.Context, info any) context.Context
- type ConnectConfig
- type ConnectServer
- type ConnectServerOption
- func Address(addr string) ConnectServerOption
- func ConnectHttpOptions(options ...connecthttp.Option) ConnectServerOption
- func Handle(pattern string, handler http.Handler) ConnectServerOption
- func HttpMiddleware(middleware ...httpo.HttpMiddleware) ConnectServerOption
- func HttpPatternHandlers(patternHandlers ...httpo.HttpPatternHandler) ConnectServerOption
- func IdleTimeout(timeout time.Duration) ConnectServerOption
- func MaxHeaderBytes(bytes int) ConnectServerOption
- func ReadHeaderTimeout(timeout time.Duration) ConnectServerOption
- func ReadTimeout(timeout time.Duration) ConnectServerOption
- func RegisterServices(fns ...RegisterFunc) ConnectServerOption
- func RegisterUtilityServices(fns ...RegisterFunc) ConnectServerOption
- func ServerInterceptors(interceptors ...connect.ServerInterceptor) ConnectServerOption
- func WithConnectConfig(config ConnectConfig) ConnectServerOption
- func WriteTimeout(timeout time.Duration) ConnectServerOption
- type RegisterFunc
Constants ¶
const ( NamedConnectConfig = "connectrpco.ConnectConfig" GroupRegisterFunc = "connectrpco.RegisterFunc" GroupUtilityRegisterFunc = "connectrpco.UtilityRegisterFunc" GroupServerInterceptor = "connectrpco.ServerInterceptor" GroupConnectHttpOption = "connectrpco.ConnectHttpOption" GroupHttpHandler = "connectrpco.HttpHandler" GroupHttpMiddleware = "connectrpco.HttpMiddleware" )
Variables ¶
This section is empty.
Functions ¶
func GetAuthnInfo ¶
GetAuthnInfo returns the authentication information attached to the context.
func NewAuthnMiddleware ¶
func NewAuthnMiddleware( authnFn func(context.Context, *http.Request) (any, error), opts ...connecthttp.Option, ) httpo.HttpMiddleware
NewAuthnMiddleware creates a Connect authentication middleware. Pass the same Connect HTTP options as the server.
func NewConnectCorsOptions ¶
NewConnectCorsOptions creates a Connect CORS options. It merges the provided options with the defaults required by Connect.
func NewCorsHandler ¶
func NewCorsHandler(config corso.Config) httpo.HttpMiddleware
NewCorsHandler creates a Connect CORS middleware for Connect HTTP handler.
func RegisterGrpcHealth ¶
RegisterGrpcHealth registers the gRPC health service. It reports every service already registered on the server as serving, so pass it to RegisterUtilityServices to run it after the application services.
func RegisterGrpcReflect ¶
RegisterGrpcReflect registers the gRPC reflection service, which describes all services registered on the server. For custom reflection options, call grpcreflect.Register directly.
Types ¶
type ConnectConfig ¶
type ConnectConfig struct {
Enabled bool `default:"true"`
Addr string `default:":8080"`
ReadHeaderTimeout time.Duration `default:"1s"`
ReadTimeout time.Duration `default:"30s"`
WriteTimeout time.Duration `default:"30s"`
IdleTimeout time.Duration `default:"120s"`
MaxHeaderBytes int `default:"8192"` // 8KiB
}
type ConnectServer ¶
ConnectServer is an HTTP server wrapper.
func NewConnectServer ¶
func NewConnectServer(opts ...ConnectServerOption) (*ConnectServer, error)
func (*ConnectServer) RPCServer ¶
func (s *ConnectServer) RPCServer() *connect.Server
RPCServer returns the underlying Connect server, e.g. for use with an in-process transport in tests.
type ConnectServerOption ¶
type ConnectServerOption func(*ConnectServer)
ConnectServerOption is an Connect server option.
func ConnectHttpOptions ¶
func ConnectHttpOptions(options ...connecthttp.Option) ConnectServerOption
ConnectHttpOptions with Connect HTTP transport options, such as read limits or compression settings. They apply to every registered service.
func Handle ¶
func Handle(pattern string, handler http.Handler) ConnectServerOption
Handle registers a new plain HTTP handler for a given pattern.
func HttpMiddleware ¶
func HttpMiddleware(middleware ...httpo.HttpMiddleware) ConnectServerOption
HttpMiddleware with server http middleware.
func HttpPatternHandlers ¶
func HttpPatternHandlers(patternHandlers ...httpo.HttpPatternHandler) ConnectServerOption
HttpPatternHandlers registers plain HTTP handlers.
func IdleTimeout ¶
func IdleTimeout(timeout time.Duration) ConnectServerOption
IdleTimeout with server idle timeout.
func MaxHeaderBytes ¶
func MaxHeaderBytes(bytes int) ConnectServerOption
MaxHeaderBytes with server max header bytes.
func ReadHeaderTimeout ¶
func ReadHeaderTimeout(timeout time.Duration) ConnectServerOption
ReadHeaderTimeout with server read header timeout.
func ReadTimeout ¶
func ReadTimeout(timeout time.Duration) ConnectServerOption
ReadTimeout with server read timeout.
func RegisterServices ¶
func RegisterServices(fns ...RegisterFunc) ConnectServerOption
RegisterServices registers Connect services. The functions run in the order they are given, after all server interceptors are known.
func RegisterUtilityServices ¶
func RegisterUtilityServices(fns ...RegisterFunc) ConnectServerOption
RegisterUtilityServices registers utility services, such as health and reflection. They run after all services passed to RegisterServices, regardless of option order, so they can inspect the registered services.
func ServerInterceptors ¶
func ServerInterceptors(interceptors ...connect.ServerInterceptor) ConnectServerOption
ServerInterceptors with Connect server interceptors. Interceptors apply to every registered service; the first one wraps the outermost call.
func WithConnectConfig ¶
func WithConnectConfig(config ConnectConfig) ConnectServerOption
WithConnectConfig with server config.
func WriteTimeout ¶
func WriteTimeout(timeout time.Duration) ConnectServerOption
WriteTimeout with server write timeout.
type RegisterFunc ¶
RegisterFunc registers one or more Connect services on a server, typically by calling a generated Register<Service>Handler function.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package connectrpcotest provides utilities for testing Connect services.
|
Package connectrpcotest provides utilities for testing Connect services. |
|
internal
|
|
|
authn
Package authn provides authentication middleware for connect.
|
Package authn provides authentication middleware for connect. |
|
echotest
Package echotest provides a minimal Connect service for tests.
|
Package echotest provides a minimal Connect service for tests. |