tink3rlabs / todo-service

2 stars 0 forks source link

Add request validation middleware #4

Closed deanefrati closed 4 months ago

Lutherwaves commented 4 months ago

Sample middleware https://github.com/tink3rlabs/example-app/blob/main/internal/middleware/middleware.go#L37

UjwalaK commented 4 months ago

I was looking into inbuilt validators and Gin framework has builtin validators where you can do request payload validation and also write custom validators https://blog.logrocket.com/gin-binding-in-go-a-tutorial-with-examples/

Reading more on Gin, its a heavy weight thats why most prefer something light weight framework like Chi the one we are using

Chi doesn't have its own inbuilt validator and its usually paired with package Validator which Gin also uses internally

For json schema there is a package gojsonschema that allows you to validate JSON payloads against a predefined JSON schema. I will look into these two libraries