Documentation
¶
Index ¶
- func BearerInterceptor(token string) connect.ClientInterceptor
- func ConnectCORS(origins []string) cors.Options
- func Error(w http.ResponseWriter, status int)
- func Handler(handler HandlerError) http.Handler
- func MountAPI(router apiRoutes, fn MountFn, interceptors ...connect.ServerInterceptor)
- func Param(r *http.Request, name string) string
- func RequestFromContext(ctx context.Context) *http.Request
- func ServerInterceptors() []connect.ServerInterceptor
- type HandlerError
- type MountFn
- type Option
- type Router
- func (r *Router) Delete(path string, handler HandlerError)
- func (r *Router) Get(path string, handler HandlerError)
- func (r *Router) Handler(handler http.Handler)
- func (r *Router) Head(path string, handler HandlerError)
- func (r *Router) Options(path string, handler HandlerError)
- func (r *Router) Patch(path string, handler HandlerError)
- func (r *Router) Post(path string, handler HandlerError)
- func (r *Router) Put(path string, handler HandlerError)
- func (r *Router) Subrouter() *mux.Router
- type Server
- type ServerPort
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BearerInterceptor ¶ added in v0.14.0
func BearerInterceptor(token string) connect.ClientInterceptor
func ConnectCORS ¶
ConnectCORS configures the standard CORS options for Connect APIs.
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
Handler adapts an error-returning function to an HTTP handler and reports returned errors.
func MountAPI ¶ added in v0.16.0
func MountAPI(router apiRoutes, fn MountFn, interceptors ...connect.ServerInterceptor)
MountAPI registers API routes on an application router served by Doris. The standard Doris interceptors run before the supplied interceptors.
func Param ¶ added in v0.16.1
Param returns a matched route parameter, or an empty string if it is missing.
func RequestFromContext ¶ added in v0.16.0
RequestFromContext returns the request attached by Doris, or nil outside a Doris handler.
func ServerInterceptors ¶
func ServerInterceptors() []connect.ServerInterceptor
Types ¶
type HandlerError ¶ added in v0.11.0
type HandlerError func(w http.ResponseWriter, r *http.Request) error
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.
type Router ¶ added in v0.10.0
func (*Router) Delete ¶ added in v0.16.0
func (r *Router) Delete(path string, handler HandlerError)
Delete registers a DELETE route.
func (*Router) Get ¶ added in v0.16.0
func (r *Router) Get(path string, handler HandlerError)
Get registers a GET route, which also handles HEAD requests.
func (*Router) Handler ¶ added in v0.15.0
Handler registers an application handler as the fallback for routes not handled by Doris.
func (*Router) Head ¶ added in v0.16.0
func (r *Router) Head(path string, handler HandlerError)
Head registers a HEAD route.
func (*Router) Options ¶ added in v0.16.0
func (r *Router) Options(path string, handler HandlerError)
Options registers an OPTIONS route.
func (*Router) Patch ¶ added in v0.16.0
func (r *Router) Patch(path string, handler HandlerError)
Patch registers a PATCH route.
func (*Router) Post ¶ added in v0.16.0
func (r *Router) Post(path string, handler HandlerError)
Post registers a POST route.
func (*Router) Put ¶ added in v0.16.0
func (r *Router) Put(path string, handler HandlerError)
Put registers a PUT route.
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) Close ¶ added in v0.13.7
func (server *Server) Close()
Close gracefully shuts down the server using the same procedure as when receiving a close signal.
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.