Download api/v3/handlers/features/error_encoder.go from Leon4gr45/openmeter: direct link, hf CLI and curl.
- Browser
- Download file 870 Bytes
-
https://huggingface.co/spaces/Leon4gr45/openmeter/resolve/main/api/v3/handlers/features/error_encoder.go
- Command line
-
hf download hf://spaces/Leon4gr45/openmeter/api/v3/handlers/features/error_encoder.go
-
curl -L -o error_encoder.go https://huggingface.co/spaces/Leon4gr45/openmeter/resolve/main/api/v3/handlers/features/error_encoder.go
870 Bytes
| package features | |
| import ( | |
| "context" | |
| "net/http" | |
| "github.com/openmeterio/openmeter/openmeter/productcatalog/feature" | |
| "github.com/openmeterio/openmeter/pkg/framework/commonhttp" | |
| "github.com/openmeterio/openmeter/pkg/framework/transport/httptransport/encoder" | |
| ) | |
| func errorEncoder() encoder.ErrorEncoder { | |
| return func(ctx context.Context, err error, w http.ResponseWriter, r *http.Request) bool { | |
| return commonhttp.HandleErrorIfTypeMatches[*feature.FeatureInvalidFiltersError](ctx, http.StatusBadRequest, err, w) || | |
| commonhttp.HandleErrorIfTypeMatches[*feature.FeatureInvalidMeterAggregationError](ctx, http.StatusBadRequest, err, w) || | |
| commonhttp.HandleErrorIfTypeMatches[*feature.ForbiddenError](ctx, http.StatusForbidden, err, w) || | |
| commonhttp.HandleErrorIfTypeMatches[*feature.FeatureWithNameAlreadyExistsError](ctx, http.StatusConflict, err, w) | |
| } | |
| } | |