add version route

This commit is contained in:
Arthur Lu 2024-07-06 02:46:10 +00:00
parent a8d35cfa6c
commit c1ff9e0ec7

View File

@ -15,6 +15,7 @@ import (
) )
var LDAPSessions map[string]*LDAPClient var LDAPSessions map[string]*LDAPClient
var APIVersion = "1.0.0"
func Run() { func Run() {
gob.Register(LDAPClient{}) gob.Register(LDAPClient{})
@ -38,6 +39,10 @@ func Run() {
LDAPSessions = make(map[string]*LDAPClient) LDAPSessions = make(map[string]*LDAPClient)
router.GET("/version", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"version": APIVersion})
})
router.POST("/ticket", func(c *gin.Context) { router.POST("/ticket", func(c *gin.Context) {
var body Login var body Login
if err := c.ShouldBind(&body); err != nil { // bad request from binding if err := c.ShouldBind(&body); err != nil { // bad request from binding