Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download api/pkg/validators/billing_handler_validator.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/83a59cae175e3c9a43b6f5d3f8749ca61b6b5072/api/pkg/validators/billing_handler_validator.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway@83a59cae175e3c9a43b6f5d3f8749ca61b6b5072/api/pkg/validators/billing_handler_validator.go
-
curl -L -o billing_handler_validator.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/83a59cae175e3c9a43b6f5d3f8749ca61b6b5072/api/pkg/validators/billing_handler_validator.go
1.17 kB
| package validators | |
| import ( | |
| "context" | |
| "fmt" | |
| "net/url" | |
| "github.com/NdoleStudio/httpsms/pkg/requests" | |
| "github.com/NdoleStudio/httpsms/pkg/telemetry" | |
| "github.com/thedevsaddam/govalidator" | |
| ) | |
| // BillingHandlerValidator validates models used in handlers.BillingHandler | |
| type BillingHandlerValidator struct { | |
| validator | |
| logger telemetry.Logger | |
| tracer telemetry.Tracer | |
| } | |
| // NewBillingHandlerValidator creates a new handlers.BillingHandler validator | |
| func NewBillingHandlerValidator( | |
| logger telemetry.Logger, | |
| tracer telemetry.Tracer, | |
| ) (v *BillingHandlerValidator) { | |
| return &BillingHandlerValidator{ | |
| logger: logger.WithService(fmt.Sprintf("%T", v)), | |
| tracer: tracer, | |
| } | |
| } | |
| // ValidateHistory validates the requests.BillingUsageHistory request | |
| func (validator *BillingHandlerValidator) ValidateHistory(_ context.Context, request requests.BillingUsageHistory) url.Values { | |
| v := govalidator.New(govalidator.Options{ | |
| Data: &request, | |
| Rules: govalidator.MapData{ | |
| "limit": []string{ | |
| "required", | |
| "numeric", | |
| "min:1", | |
| "max:100", | |
| }, | |
| "skip": []string{ | |
| "required", | |
| "numeric", | |
| "min:0", | |
| }, | |
| }, | |
| }) | |
| return v.ValidateStruct() | |
| } | |