Documentation ¶
Index ¶
- func ConnectHandlerOptions() []connect.HandlerOption
- func EnableDocsFirebaseAuth(s *Server, domain string)
- func HandleConnectUnary[Req any, Resp any](s *Server, procedure string, ...)
- func Main[T config.CurioStack](conf T, confFiles fs.FS, ...) int
- func Mux(s *Server) *chi.Mux
- func NewMux() *chi.Mux
- func NewServer(router http.Handler, conf *config.Common) *http.Server
- func Start(ctx context.Context, s *Server) error
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectHandlerOptions ¶
func ConnectHandlerOptions() []connect.HandlerOption
ConnectHandlerOptions returns the default options for connect handlers.
func EnableDocsFirebaseAuth ¶
EnableDocsFirebaseAuth enables Firebase auth for the docs handler. The domain must be the auth domain of the Firebase project.
Firebase credentials of the browser, generally set by running the actual web app locally, will be read and added as authorization headers in requests to the server.
func HandleConnectUnary ¶
func HandleConnectUnary[Req any, Resp any]( s *Server, procedure string, handler func(ctx context.Context, req *Req) (*Resp, error), sampleRequests []*Req, opts ...connect.HandlerOption, )
HandleConnectUnary mounts a connect unary handler for the given procedure with the given handler. Sample requests will be displayed in the docs interface and is recommended to be provided whenever possible.
func Main ¶
func Main[T config.CurioStack](conf T, confFiles fs.FS, run func(ctx context.Context, conf T, b *Server) error) int
Main is the entrypoint for starting a server using CurioStack. It should be called from your main function and passed a pointer to your configuration object which embeds config.Common. The setup callback should set up handlers and such using methods on Server to define the resulting server. It must finish setup by calling Server.Start to start the server.
If you need to define default values before loading user config, they should be set on the config before passing, or otherwise it is fine to just pass a pointer to an empty struct. confFiles is a fs.FS to resolve config files as used by config.Load.
An exit code is returned, so the general pattern for this function will be to call os.Exit with the result of this function.
func Mux ¶
func Mux(s *Server) *chi.Mux
Mux returns the chi.Mux that will be served and can be used to add route handlers.
For connect handlers it is strongly preferred to use HandleConnectUnary instead to allow registration of default interceptors and docs handler.