36 lines
963 B
Go
36 lines
963 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/contrib/static"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func main() {
|
|
// Set the router as the default one shipped with Gin
|
|
router := gin.Default()
|
|
|
|
// Serve frontend static files
|
|
router.Use(static.Serve("/", static.LocalFile("./views", true)))
|
|
|
|
// Setup route group for the API
|
|
api := router.Group("/api")
|
|
{
|
|
api.GET("/", func(c *gin.Context) {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"message": "pong",
|
|
})
|
|
})
|
|
}
|
|
|
|
api.GET("/getUsersView", getUsersView) //widok pobrania wszystkich użytkowników
|
|
api.POST("/addNewUserView", addNewUserView) // json z danymi nowego uzytkownika
|
|
api.POST("/loginUserView", loginUserView) //logowanie
|
|
api.POST("/updateUserPointsView", updateUserPointsView) // inkrementacja punktow
|
|
api.POST("/addNewCardView", addNewCardView) // [couchdb] dodawanie nowej karty
|
|
|
|
// Start and run the server
|
|
router.Run(":3000")
|
|
}
|