Documentation
¶
Index ¶
- func RegisterAuthRoutes(oidc *iam.OIDC, mux *AuthMux) error
- func SetOriginHeader(h http.Handler) http.Handler
- type AssetsFileSystemProvider
- func NewDefaultAssetsFileSystemProvider(staticAssets string) AssetsFileSystemProvider
- func NewEmbeddedAssetsFileSystemProvider(embeddedFS embed.FS, subPath string) AssetsFileSystemProvider
- func NewFallbackAssetsFileSystemProvider(providers ...AssetsFileSystemProvider) AssetsFileSystemProvider
- func NewStaticAssetsFileSystemProvider(staticAssets string) AssetsFileSystemProvider
- type AuthMux
- func (p *AuthMux) Handle(pattern string, handler http.Handler)
- func (p *AuthMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (p *AuthMux) HandleProtected(pattern string, handler http.Handler, checker iam.Checker, role string)
- func (p *AuthMux) HandleProtectedFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (p *AuthMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Options
- type RegisterHandlers
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterAuthRoutes ¶
RegisterAuthRoutes registers the OAuth2 authentication routes
func SetOriginHeader ¶
SetOriginHeader is middleware that copies the Origin header from the request to the response This is necessary when using AllowAllOrigins because the browser will complain if the response header is the "*" and not the same origin as on the request. The cors handler in the connect library doesn't do this by default.
Types ¶
type AssetsFileSystemProvider ¶ added in v3.16.5
AssetsFileSystemProvider is an interface for providing asset filesystems. This allows the server to be decoupled from how assets are constructed.
func NewDefaultAssetsFileSystemProvider ¶ added in v3.16.5
func NewDefaultAssetsFileSystemProvider(staticAssets string) AssetsFileSystemProvider
NewDefaultAssetsFileSystemProvider creates a new default asset filesystem provider that tries static assets first, then embedded assets as a fallback. This preserves the original behavior of getAssetsFileSystem.
func NewEmbeddedAssetsFileSystemProvider ¶ added in v3.16.5
func NewEmbeddedAssetsFileSystemProvider(embeddedFS embed.FS, subPath string) AssetsFileSystemProvider
NewEmbeddedAssetsFileSystemProvider creates a provider that serves assets from embedded files. The subPath parameter specifies the subdirectory within the embedded filesystem (e.g., "dist").
func NewFallbackAssetsFileSystemProvider ¶ added in v3.16.5
func NewFallbackAssetsFileSystemProvider(providers ...AssetsFileSystemProvider) AssetsFileSystemProvider
NewFallbackAssetsFileSystemProvider creates a provider that tries multiple providers in order until one succeeds. Returns the first error if all providers fail.
func NewStaticAssetsFileSystemProvider ¶ added in v3.16.5
func NewStaticAssetsFileSystemProvider(staticAssets string) AssetsFileSystemProvider
NewStaticAssetsFileSystemProvider creates a provider that serves assets from a directory.
type AuthMux ¶
type AuthMux struct {
// contains filtered or unexported fields
}
AuthMux wraps http.ServeMux to add protected route handling
func NewAuthMux ¶
NewAuthMux creates a new AuthMux
func (*AuthMux) HandleFunc ¶
HandleFunc registers a handler function for the given pattern
func (*AuthMux) HandleProtected ¶
func (p *AuthMux) HandleProtected(pattern string, handler http.Handler, checker iam.Checker, role string)
HandleProtected registers a protected handler for the given pattern
func (*AuthMux) HandleProtectedFunc ¶
func (p *AuthMux) HandleProtectedFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
HandleProtectedFunc registers a protected handler function for the given pattern
type Options ¶
type Options struct {
Telemetry *config.TelemetryConfig
Server *config.AssistantServerConfig
WebApp *agentv1.WebAppConfig
IAMPolicy *api.IAMPolicy
// RegisterHandlers is a callback that allows you to register additional handlers in the server.
// These could be regular HTTP handlers or proto services.
RegisterHandlers RegisterHandlers
// AssetsFileSystemProvider is an optional asset filesystem provider. If nil, a default implementation
// will be used when the agent is enabled.
AssetsFileSystemProvider AssetsFileSystemProvider
}
type RegisterHandlers ¶ added in v3.15.1
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main server for the cloud assistant
func NewServer ¶
func NewServer(opts Options, agent agentv1connect.MessagesServiceHandler) (*Server, error)
NewServer creates a new server