-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request Validation #14
Conversation
I started working on implementing a middleware to decode the JSON into our model. But kind of hit a roadblock. I don't think it is possible to implement a single function that can decode all requests into corresponding models since golang doesn't support generics. Since we cannot decode the request into the API models, it is not possible to use the Validate function as it is right now. I was thinking that we can instead use The other way would be to decode and validate inside each handler itself. Although I don't think it will be useful since we will have to implement a separate I would say the What do you think @daltonfury42 @maaverik ? |
I see. Can I get on a call with you and then we can try the middleware approach together? I see some support of generics, we can see if it will work: https://go.dev/doc/tutorial/generics |
As discussed with @daltonfury42 over call, we should go for decoding and validation of request body inside the handler itself as other approaches are unnecessarily complex specially given the small number of handlers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you resolve the file conflicts pls?
Resolved conflicts with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
@daltonfury42 any idea why the status checks aren't running here? |
I was thinking it might be waiting for the 2 reviews to be completed before running checks. |
I'm pretty sure that's not the issue, the checks normally run as soon as code is committed to the PR. I thought it might be due to a setting I had added to make sure the code is up-to-date with main on each PR, but I tried disabling that and reopened this PR (that shouldn't have caused a problem anyway since you merged with main), still nothing. I'll spend time later and try to figure it out, else we'll skip the checks this time. |
My guess is that it will not run against these commits from other action. It's either a bug or some feature to stop infinite loop of commits or maybe a security feature for some sake. @aneeshsharma can you try adding some empty/random commit to unblock. Or maybe the commits by an action doesn't qualify as a push. |
84a9d55
The checks work now. @daltonfury42 Can you please review the changes? |
As discussed earlier in #12, divided the models among API and DB models
internal/models/api/
internal/models/db/
Implemented some basic validation for a Create Queue request
Validate
method onCreateQueueRequest
QueueName
to make sure its between 4 and 20Next steps would be to
I need to look into how to proceed with implementing middleware in such a way as to have the parsed JSON passed down to subsequent middlewares or the handler.