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/lemonsqueezy_handler_validator.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/validators/lemonsqueezy_handler_validator.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway/api/pkg/validators/lemonsqueezy_handler_validator.go
-
curl -L -o lemonsqueezy_handler_validator.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/validators/lemonsqueezy_handler_validator.go
1.21 kB
| package validators | |
| import ( | |
| "context" | |
| "fmt" | |
| "net/url" | |
| "github.com/NdoleStudio/httpsms/pkg/telemetry" | |
| lemonsqueezy "github.com/NdoleStudio/lemonsqueezy-go" | |
| ) | |
| // LemonsqueezyHandlerValidator validates models used in handlers.LemonsqueezyHandler | |
| type LemonsqueezyHandlerValidator struct { | |
| logger telemetry.Logger | |
| tracer telemetry.Tracer | |
| client *lemonsqueezy.Client | |
| } | |
| // NewLemonsqueezyHandlerValidator creates a new handlers.LemonsqueezyHandler validator | |
| func NewLemonsqueezyHandlerValidator( | |
| logger telemetry.Logger, | |
| tracer telemetry.Tracer, | |
| client *lemonsqueezy.Client, | |
| ) (v *LemonsqueezyHandlerValidator) { | |
| return &LemonsqueezyHandlerValidator{ | |
| logger: logger.WithService(fmt.Sprintf("%T", v)), | |
| tracer: tracer, | |
| client: client, | |
| } | |
| } | |
| // ValidateEvent checks that an event is coming from lemonsqueezy | |
| func (validator *LemonsqueezyHandlerValidator) ValidateEvent(ctx context.Context, signature string, request []byte) url.Values { | |
| _, span := validator.tracer.Start(ctx) | |
| defer span.End() | |
| isValid := validator.client.Webhooks.Verify(ctx, signature, request) | |
| if !isValid { | |
| return url.Values{ | |
| "body": []string{ | |
| "The signature is not valid", | |
| }, | |
| } | |
| } | |
| return url.Values{} | |
| } | |