Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v1.11.0

- chore: improve kakfa component
- chore: improve route not found method

## v1.10.0

Expand Down
15 changes: 14 additions & 1 deletion pkg/app/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,20 @@ func (r *Response) Error(c *gin.Context, err error) {

// RouteNotFound 未找到相关路由
func RouteNotFound(c *gin.Context) {
c.String(http.StatusNotFound, "the route not found")
accept := c.GetHeader("Accept")
if accept == "" {
accept = c.ContentType()
}
if accept == "application/json" || accept == "application/json; charset=utf-8" {
response := Response{
Code: http.StatusNotFound,
Message: "the route not found",
Data: gin.H{},
}
c.JSON(http.StatusNotFound, response)
} else {
c.String(http.StatusNotFound, "the route not found")
}
}

// healthCheckResponse 健康检查响应结构体
Expand Down
Loading