Skip to content

Interceptors

func Envelope(ec dygo.ExecutionContext, next dygo.CallHandler) (any, error) {
out, err := next.Handle() // runs later interceptors, pipes and the handler
if err != nil {
return nil, err
}
return map[string]any{"data": out}, nil
}
r.Get("/x", h, dygo.Interceptors(Envelope))

Not calling next.Handle() skips the handler (a cache); calling it twice retries. Built-ins: interceptors.Timeout(5*time.Second) (408 when the handler gives up on its deadline; the handler must honour ctx) and interceptors.Logging(log).