get users request

This commit is contained in:
cyrus 2024-05-28 22:10:09 +00:00
parent 89397ec70f
commit 1f700048a4
2 changed files with 33 additions and 7 deletions

29
main.go
View File

@ -1,25 +1,40 @@
package main
import (
"bytes"
"fmt"
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.GET("/version", func(c *gin.Context) {
c.JSON(200, gin.H{
"version": "0.0.1",
})
})
router.POST("/echo", func(c *gin.Context) {
buf := new(bytes.Buffer)
buf.ReadFrom(c.Request.Body)
data := buf.String()
fmt.Println(data)
router.GET("/users", func(c *gin.Context) {})
router.POST("/users/:userid", func(c *gin.Context) {
var user User
if err := c.ShouldBind(&user); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
user.Id = c.Param("userid")
c.JSON(http.StatusOK, user)
})
router.GET("/users/:userid", func(c *gin.Context) {})
router.DELETE("/users/:userid", func(c *gin.Context) {})
router.GET("/groups", func(c *gin.Context) {})
router.POST("/groups/:groupid", func(c *gin.Context) {})
router.GET("/groups/:groupid", func(c *gin.Context) {})
router.DELETE("/groups/:groupid", func(c *gin.Context) {})
router.POST("/groups/:groupid/members/:userid", func(c *gin.Context) {})
router.DELETE("/groups/:groupid/members/:userid", func(c *gin.Context) {})
router.Run("0.0.0.0:80") // listen and serve on 0.0.0.0:8080
}

11
request_types.go Normal file
View File

@ -0,0 +1,11 @@
package main
type User struct {
Id string
Password string `form:"userpassword" binding:"required"`
CN string `form:"usercn" binding:"required"`
SN string `form:"usersn" binding:"required"`
Resources struct{}
Cluster struct{}
Templates struct{}
}