-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
7,031 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,27 @@ | ||
package hosts | ||
|
||
import ( | ||
"net/http" | ||
"fmt" | ||
//"net/http" | ||
//"fmt" | ||
|
||
"github.com/gin-gonic/gin" | ||
//"github.com/sirupsen/logrus" | ||
"github.com/sirupsen/logrus" | ||
) | ||
type hosts struct { | ||
id string `form:"id" json:"id" binding:"required"` | ||
} | ||
|
||
func Start(group *gin.RouterGroup) { | ||
|
||
group.POST("/", func(c *gin.Context) { | ||
c.String(http.StatusOK, "hello world") | ||
}) | ||
|
||
var handlerFuncList = make(map[string]gin.HandlerFunc) | ||
|
||
//logrus.WithFields(logrus.Fields{ | ||
// "n": n, | ||
// "error": err, | ||
//}).Error("exec prefix") | ||
|
||
group.GET("/user/:name/*action", func(c *gin.Context) { | ||
name := c.Param("name") | ||
action := c.Param("action") | ||
message := name + " is " + action | ||
c.String(http.StatusOK, message) | ||
}) | ||
|
||
group.POST("/post", func(c *gin.Context) { | ||
func Start(group *gin.RouterGroup) { | ||
|
||
id := c.PostForm("id") | ||
page := c.PostForm("page") | ||
name := c.PostForm("name") | ||
message := c.PostForm("message") | ||
if group == nil { | ||
logrus.Error("admin start failed.") | ||
return | ||
} | ||
|
||
fmt.Printf("id: %s; page: %s; name: %s; message: %s", id, page, name, message) | ||
messages := "id:" | ||
messages += id | ||
messages += ",page:" | ||
messages += page | ||
messages += ",name:" | ||
messages += name | ||
messages += ",message:" | ||
messages += message | ||
c.String(http.StatusOK, messages) | ||
}) | ||
for key, value := range handlerFuncList { | ||
group.POST(key, value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package hosts | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"time" | ||
"github.com/mds1455975151/cmdb/utils" | ||
"net/http" | ||
) | ||
|
||
func init() { | ||
|
||
handlerFuncList["/hosts"] = hostitem | ||
} | ||
|
||
// | ||
// Request Hosts Item | ||
// | ||
type HostsItemReq struct { | ||
// The globalId | ||
// | ||
// Required: true | ||
GlobalId int64 `form:"globalId" json:"globalId" binding:"required"` | ||
} | ||
|
||
// | ||
// 应答: 协议返回包 | ||
// swagger:response DoBuyItemRsp | ||
// noinspection ALL | ||
type HostsItemRsp struct { | ||
// in: body | ||
Body struct { | ||
// The response code | ||
// | ||
// Required: true | ||
Code int64 `json:"code"` | ||
// The response message | ||
// | ||
// Required: true | ||
Message string `json:"message"` | ||
// The payment sequence to identify the flow. | ||
// | ||
// Required: true | ||
Sequence string `json:"sequence"` | ||
// The response BuyItem | ||
// | ||
// Required: true | ||
BuyItemMidas struct { | ||
// | ||
// ret为0的时候,返回真正购买物品的url的参数,开发者需要把该参数 | ||
// 传给sdk跳转到相关页面使用户完成真正的购买动作。 | ||
// | ||
UrlParams string `json:"url_params"` | ||
} `json:"buyItemMidas"` | ||
} | ||
} | ||
|
||
// | ||
// swagger:route POST /payment/buy_item payment payment_buy_item | ||
// | ||
// Return buy item for the given user: | ||
// | ||
// Consumes: | ||
// - application/json | ||
// | ||
// Produces: | ||
// - application/json | ||
// | ||
// Schemes: http, https | ||
// | ||
// Responses: | ||
// 200: DoBuyItemRsp | ||
func hostitem(c *gin.Context) { | ||
|
||
c.JSON(http.StatusOK, resp.Body) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.