Skip to content

Commit

Permalink
fix: fix query request api key bug and add name key
Browse files Browse the repository at this point in the history
  • Loading branch information
freeshineit committed May 29, 2023
1 parent 91f3e16 commit c5db31a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions public/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@

// 成功
$(".query").on("click", function () {
var data = getFormValue();
axios
.get("/api/query", {
params: {
message: "message",
nick: "ShineShao"
name: data.name,
message: data.message,
nick: data.nick
}
})
.then((res) => {
Expand Down
8 changes: 5 additions & 3 deletions router/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func SetupRoutes() *gin.Engine {
apiGroup.POST("/json_post", api.JSONPost)

//url encode 提交
apiGroup.POST("/urlencoded_post", api.UrlencodedPost)

apiGroup.POST("/urlencoded_post", api.UrlencodedPost)
// 即支持json又支持form
apiGroup.POST("/json_and_form_post", api.JSONAndFormPost)

Expand All @@ -59,12 +59,14 @@ func SetupRoutes() *gin.Engine {
apiGroup.POST("/file_chunk_upload", api.FileChunkUpload)

apiGroup.GET("/query", func(c *gin.Context) {
name := c.Query("name")
message := c.Query("message")
nick := c.DefaultQuery("nick", "anonymous")

c.JSON(http.StatusOK, helper.BuildResponse(gin.H{
message: message,
nick: nick,
"name": name,
"message": message,
"nick": nick,
}))
})
}
Expand Down

0 comments on commit c5db31a

Please sign in to comment.