Documentation
¶
Index ¶
- func AuthenticateInterceptor(a auth.Authenticator, cls SchemeClassifier) connect.Interceptor
- func AuthorizeInterceptor(az auth.Authorizer, actions map[string]auth.Action) connect.Interceptor
- func MetricsInterceptor(m *observability.Metrics) connect.Interceptor
- func RecoverInterceptor() connect.Interceptor
- func RequestIDInterceptor() connect.Interceptor
- func SlogInterceptor() connect.Interceptor
- func WithPeerCred(ctx context.Context, c *auth.PeerCred) context.Context
- type Config
- type Deps
- type Listener
- type Route
- type SchemeClassifier
- type Services
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthenticateInterceptor ¶
func AuthenticateInterceptor(a auth.Authenticator, cls SchemeClassifier) connect.Interceptor
AuthenticateInterceptor runs the Authenticator against every request and attaches the resulting Principal to the context. Returns CodeUnauthenticated if authentication fails.
func AuthorizeInterceptor ¶
func AuthorizeInterceptor(az auth.Authorizer, actions map[string]auth.Action) connect.Interceptor
AuthorizeInterceptor checks the principal in ctx against the action map. Procedures not in the map are allowed through unconditionally.
func MetricsInterceptor ¶
func MetricsInterceptor(m *observability.Metrics) connect.Interceptor
MetricsInterceptor records per-procedure request count and latency via the gohome_api_* Prometheus metrics.
func RecoverInterceptor ¶
func RecoverInterceptor() connect.Interceptor
RecoverInterceptor catches panics from downstream handlers and converts them to connect.CodeInternal errors, logging the stack trace.
func RequestIDInterceptor ¶
func RequestIDInterceptor() connect.Interceptor
RequestIDInterceptor mints or echoes the X-Request-Id header and stores the value in the request context via observability.WithRequestID.
func SlogInterceptor ¶
func SlogInterceptor() connect.Interceptor
SlogInterceptor logs each completed RPC with method, code, duration, and request-id.
Types ¶
type Route ¶
func BuildRoutes ¶
func BuildRoutes(svc Services, interceptors ...connect.Interceptor) []Route
BuildRoutes returns the (path, handler) pairs to mount on the listener mux. NewXServiceHandler returns (string, http.Handler).
type SchemeClassifier ¶
type SchemeClassifier interface {
Classify(req connect.AnyRequest) (scheme string, isUDS bool)
}
SchemeClassifier classifies a request into an auth scheme and whether it arrived on the Unix-domain socket.
type Services ¶
type Services struct {
System gohomev1alpha1connect.SystemServiceHandler
Area gohomev1alpha1connect.AreaServiceHandler
Zone gohomev1alpha1connect.ZoneServiceHandler
Device gohomev1alpha1connect.DeviceServiceHandler
Entity gohomev1alpha1connect.EntityServiceHandler
Driver gohomev1alpha1connect.DriverServiceHandler
Event gohomev1alpha1connect.EventServiceHandler
Config gohomev1alpha1connect.ConfigServiceHandler
Automation gohomev1alpha1connect.AutomationServiceHandler
Script gohomev1alpha1connect.ScriptServiceHandler
Scene gohomev1alpha1connect.SceneServiceHandler
Dashboard gohomev1alpha1connect.DashboardServiceHandler
Auth gohomev1alpha1connect.AuthServiceHandler
}
Services is the set of handler implementations the listener needs.