Documentation ¶
Index ¶
- func Connect(r *routing.Router, fn RegisterFn)deprecated
- func ConnectCORS(origins []string) cors.Optionsdeprecated
- func ConnectOptions(interceptors ...connect.Interceptor) []connect.HandlerOptiondeprecated
- func Error(w http.ResponseWriter, status int)
- func Errorf(code connect.Code, msg string, args ...any) error
- func Handler(handler HandlerError) http.Handler
- func ServerInterceptors() []connect.Interceptor
- type ConnectHub
- type ConnectHubOption
- type HandlerError
- type MountFn
- type Option
- type RegisterFndeprecated
- type Router
- type Server
- type ServerPort
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect
deprecated
func Connect(r *routing.Router, fn RegisterFn)
Deprecated: Use NewConnectHub instead.
func ConnectCORS
deprecated
func ConnectOptions
deprecated
added in
v0.1.1
func ConnectOptions(interceptors ...connect.Interceptor) []connect.HandlerOption
Deprecated: Use NewConnectHub instead.
func Error ¶ added in v0.11.1
func Error(w http.ResponseWriter, status int)
func Handler ¶ added in v0.11.0
func Handler(handler HandlerError) http.Handler
func ServerInterceptors ¶
func ServerInterceptors() []connect.Interceptor
Types ¶
type ConnectHub ¶ added in v0.3.0
type ConnectHub struct {
// contains filtered or unexported fields
}
ConnectHub helps mounting Connect APIs to their correct endpoints.
func NewConnectHub ¶ added in v0.3.0
func NewConnectHub(r *Router, opts ...ConnectHubOption) *ConnectHub
NewConnectHub creates a new hub prepared to mount Connect APIs.
func (*ConnectHub) Mount ¶ added in v0.3.0
func (hub *ConnectHub) Mount(fn MountFn)
Mount a new API.
type ConnectHubOption ¶ added in v0.3.0
type ConnectHubOption func(cnf *ConnectHub)
ConnectHubOption configures the Connect hub.
func WithCORS ¶ added in v0.3.0
func WithCORS(domains ...string) ConnectHubOption
WithCORS configures the domains authorized to access the API. The standard studio.buf.build is always authorized by default.
func WithInterceptors ¶ added in v0.3.0
func WithInterceptors(interceptors ...connect.Interceptor) ConnectHubOption
WithInterceptors configures the interceptors to configure in the APIs.
type HandlerError ¶ added in v0.11.0
type HandlerError func(w http.ResponseWriter, r *http.Request) error
type MountFn ¶ added in v0.3.0
type MountFn func(opts ...connect.HandlerOption) (string, http.Handler)
MountFn should be implemented by a global function in the API package to register itself.
type Option ¶
type Option func(s *Server, sp *ServerPort, internal bool)
Option of a server.
func WithInternal ¶ added in v0.8.0
WithInternal apply the options to the internal server with metrics and health checks. For example it can be used to change the port of the internal server. It only makes sense if enabled at the server level, not in any individual server port.
func WithListener ¶ added in v0.4.0
WithListener configures the listener to use for the web server. It is useful to serve in custom configurations like a Unix socket or Tailscale.
func WithPort ¶ added in v0.7.0
WithPort changes the default port of the application. If the env variable PORT is defined it will override anything configured here.
func WithRoutingOptions ¶
func WithRoutingOptions(opts ...routing.ServerOption) Option
WithRoutingOptions configures web server options.
type RegisterFn
deprecated
type Router ¶ added in v0.10.0
type Server ¶
type Server struct { *ServerPort // contains filtered or unexported fields }
Server is the root server of the application.
func NewServer ¶
NewServer creates a new root server in the default port. It won't start until you call Serve() on it.
func (*Server) Context ¶
Context returns a context that will be canceled when the server is stopped.
func (*Server) GoBackground ¶ added in v0.5.0
GoBackground runs a background goroutine that will be canceled when the server is stopped. The function should return when the context is canceled. If the function returns an error, the server will be stopped prematurely. The server will not exit until all background goroutines have finished.
func (*Server) RegisterPort ¶ added in v0.7.0
func (server *Server) RegisterPort(port string, opts ...Option) *ServerPort
Register a new child server in a different port.
type ServerPort ¶ added in v0.7.0
type ServerPort struct { *Router // contains filtered or unexported fields }
ServerPort is a child server in a different custom port.