Download billing/httpdriver/errors.go from Leon4gr45/openmeter: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/Leon4gr45/openmeter/resolve/main/billing/httpdriver/errors.go
- Command line
-
hf download hf://spaces/Leon4gr45/openmeter/billing/httpdriver/errors.go
-
curl -L -o errors.go https://huggingface.co/spaces/Leon4gr45/openmeter/resolve/main/billing/httpdriver/errors.go
1.06 kB
| package httpdriver | |
| import ( | |
| "context" | |
| "net/http" | |
| "github.com/openmeterio/openmeter/openmeter/billing" | |
| "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[billing.NotFoundError](ctx, http.StatusNotFound, err, w, billing.EncodeValidationIssues) || | |
| commonhttp.HandleErrorIfTypeMatches[billing.ValidationError](ctx, http.StatusBadRequest, err, w, billing.EncodeValidationIssues) || | |
| commonhttp.HandleErrorIfTypeMatches[billing.UpdateAfterDeleteError](ctx, http.StatusConflict, err, w, billing.EncodeValidationIssues) || | |
| commonhttp.HandleErrorIfTypeMatches[billing.ValidationIssue](ctx, http.StatusBadRequest, err, w, billing.EncodeValidationIssues) || | |
| // dependency: apps | |
| commonhttp.HandleErrorIfTypeMatches[billing.AppError](ctx, http.StatusBadRequest, err, w) | |
| } | |
| } | |