adding rest-api

This commit is contained in:
2026-07-08 06:59:16 -05:00
parent 0ef9b90bcd
commit 60c2f20fea
20 changed files with 524 additions and 0 deletions

28
rest-api/routes/users.go Normal file
View File

@@ -0,0 +1,28 @@
package routes
import (
"net/http"
"example.com/rest-api/models"
"github.com/gin-gonic/gin"
)
func signup(context *gin.Context) {
var user models.User
err := context.ShouldBindJSON(&user)
if err != nil {
context.JSON(http.StatusBadRequest, gin.H{"message": "Could not parse request data."})
return
}
err = user.Save()
if err != nil {
context.JSON(http.StatusInternalServerError, gin.H{"message": "Could not save user."})
return
}
context.JSON(http.StatusCreated, gin.H{"message": "User created successfully"})
}