Skip to content
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

Transform and Validate Gin input #311

Merged
merged 2 commits into from
Dec 26, 2024
Merged

Transform and Validate Gin input #311

merged 2 commits into from
Dec 26, 2024

Conversation

EwenQuim
Copy link
Member

Adds the Transform and Validate capabilities of Fuego into the Gin adaptor

@EwenQuim EwenQuim merged commit b66dfc2 into main Dec 26, 2024
7 checks passed
@EwenQuim EwenQuim deleted the transform-and-validate-gin branch December 26, 2024 16:46
Comment on lines +106 to 117
if c.DefaultStatusCode == 0 {
c.DefaultStatusCode = http.StatusOK
}
status := c.ginCtx.Writer.Status()
if status == 0 {
status = c.DefaultStatusCode
}
if status == 0 {
status = 200
}
c.ginCtx.JSON(status, data)
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if c.DefaultStatusCode == 0 {
c.DefaultStatusCode = http.StatusOK
}
status := c.ginCtx.Writer.Status()
if status == 0 {
status = c.DefaultStatusCode
}
if status == 0 {
status = 200
}
c.ginCtx.JSON(status, data)
return nil
status := c.ginCtx.Writer.Status()
if status == 0 {
status = c.DefaultStatusCode
}
if status == 0 {
status = http.StatusOK
}
c.ginCtx.JSON(status, data)
return nil

Or

Suggested change
if c.DefaultStatusCode == 0 {
c.DefaultStatusCode = http.StatusOK
}
status := c.ginCtx.Writer.Status()
if status == 0 {
status = c.DefaultStatusCode
}
if status == 0 {
status = 200
}
c.ginCtx.JSON(status, data)
return nil
if c.DefaultStatusCode == 0 {
c.DefaultStatusCode = http.StatusOK
}
status := c.ginCtx.Writer.Status()
if status == 0 {
status = c.DefaultStatusCode
}
c.ginCtx.JSON(status, data)
return nil

Because otherwise you are doing twice

@EwenQuim EwenQuim mentioned this pull request Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants