mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-20 23:07:33 +00:00
7b5135e637
* fix(adminAPI): localisation of event types, aggregate types * fix(adminAPI): validations of ListEvent request * implement caching of editor user information
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/logging"
|
|
"google.golang.org/grpc"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
_ "github.com/zitadel/zitadel/internal/statik"
|
|
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
|
)
|
|
|
|
func TranslationHandler() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
|
resp, err := handler(ctx, req)
|
|
ctx, span := tracing.NewSpan(ctx)
|
|
defer func() { span.EndWithError(err) }()
|
|
|
|
if loc, ok := resp.(localizers); ok && resp != nil {
|
|
translator, translatorError := newZitadelTranslator(authz.GetInstance(ctx).DefaultLanguage())
|
|
if translatorError != nil {
|
|
logging.New().WithError(translatorError).Error("could not load translator")
|
|
return resp, err
|
|
}
|
|
translateFields(ctx, loc, translator)
|
|
}
|
|
if err != nil {
|
|
translator, translatorError := newZitadelTranslator(authz.GetInstance(ctx).DefaultLanguage())
|
|
if translatorError != nil {
|
|
logging.New().WithError(translatorError).Error("could not load translator")
|
|
return resp, err
|
|
}
|
|
err = translateError(ctx, err, translator)
|
|
}
|
|
return resp, err
|
|
}
|
|
}
|