Documentation
¶
Index ¶
- func ErrorHandler() func(http.Handler) http.Handler
- func HandleError(ctx context.Context, w http.ResponseWriter, err error)
- func ObsTagsMiddleware(next http.Handler) http.Handler
- func PanicRecoveryMiddleware(next http.Handler) http.Handler
- func RequestIDMiddleware(next http.Handler) http.Handler
- type Definition
- type Definitions
- type ErrorBody
- type ErrorResponse
- type Metrics
- type RequestConfig
- type Translation
- type TranslationInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorHandler ¶
ErrorHandler is a middleware that handles application errors. Kept for backward compatibility.
func HandleError ¶
func HandleError(ctx context.Context, w http.ResponseWriter, err error)
HandleError writes a structured error response and records the error on the active OTel span. Call once at the HTTP boundary — never in internal layers.
func ObsTagsMiddleware ¶
ObsTagsMiddleware reads the X-Obs-Tags request header and injects the listed tags as W3C Baggage members so they propagate automatically to all downstream service calls and NATS messages.
Header format: X-Obs-Tags: cache,persistence,domain Supported tags: cache, persistence, domain, all
Downstream code checks tags via libobs.Has(ctx, "cache").
func PanicRecoveryMiddleware ¶
PanicRecoveryMiddleware recovers from panics, records them on the active span, force-flushes the tracer provider so the span is not lost, and returns a 500. Must be the outermost middleware.
Types ¶
type Definition ¶
type Definition struct {
Translator *libtranslator.ServiceDefinition
GenDomain string
Create *RequestConfig
Update *RequestConfig
Delete *RequestConfig
CustomQueries []*libtranslator.CustomRequest
CustomCommands []*libtranslator.CustomRequest
DisableSelect bool
DisableCreate bool
DisableUpdate bool
DisableDelete bool
Event bool
// contains filtered or unexported fields
}
Definition is used to declare the information of a model, so it can generate its code.
func (*Definition) Aggregate ¶
func (d *Definition) Aggregate() *libtranslator.AggregateDefinition
func (*Definition) CustomRequests ¶
func (d *Definition) CustomRequests() []*libtranslator.CustomRequest
type Definitions ¶
type Definitions struct {
Prefix string
Name string
Repository string
TranslatorPath string
Tenant bool
Auth bool
// contains filtered or unexported fields
}
Definitions contains all the graphql definitions in the service.
func (*Definitions) GetByID ¶
func (ds *Definitions) GetByID(id string) *Definition
GetByID return the specified definition by its ID.
func (*Definitions) GetTitle ¶
func (ds *Definitions) GetTitle() string
GetTitle is used to return the name of the definition with InitCap
func (*Definitions) Register ¶
func (ds *Definitions) Register(d *Definition)
Register is used to register a new definition into the service.
func (*Definitions) Slice ¶
func (ds *Definitions) Slice() []*Definition
Slice return the definitions as a slice.
type ErrorBody ¶
type ErrorBody struct {
Code string `json:"code"`
Message string `json:"message"`
Details []string `json:"details,omitempty"`
RequestID string `json:"request_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
}
ErrorBody is the standard error response shape across all services.
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorBody `json:"error"`
}
ErrorResponse is the top-level error response envelope.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics holds the OTel instruments for HTTP request observability.
func NewMetrics ¶
NewMetrics initialises the metric instruments for a service. serviceName should match the OTel service.name resource attribute.
func (*Metrics) MetricsMiddleware ¶
MetricsMiddleware records request count and duration. Wrap after otelhttp so the span already exists when this runs. Pass the tenant_id attribute if available.
type RequestConfig ¶
type RequestConfig struct{}