mirror of
https://github.com/Uttkarsh-raj/Plannerly.git
synced 2025-11-23 21:54:39 +02:00
35 lines
656 B
Go
35 lines
656 B
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"log"
|
||
|
|
"os"
|
||
|
|
|
||
|
|
"github.com/Uttkarsh-raj/To_Do_App/middleware"
|
||
|
|
"github.com/Uttkarsh-raj/To_Do_App/routes"
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
func main() {
|
||
|
|
fmt.Println("Hello gophers")
|
||
|
|
port := os.Getenv("PORT")
|
||
|
|
if port == "" {
|
||
|
|
port = "8000"
|
||
|
|
}
|
||
|
|
router := gin.New()
|
||
|
|
router.Use(gin.Logger())
|
||
|
|
routes.UserRoutes(router)
|
||
|
|
|
||
|
|
router.Use(middleware.Authentication())
|
||
|
|
|
||
|
|
router.GET("/api-1", func(ctx *gin.Context) {
|
||
|
|
ctx.JSON(200, gin.H{"success": "Access granted for api-1"})
|
||
|
|
})
|
||
|
|
|
||
|
|
router.GET("/api-2", func(ctx *gin.Context) {
|
||
|
|
ctx.JSON(200, gin.H{"success": "Access granted for api-2"})
|
||
|
|
})
|
||
|
|
|
||
|
|
log.Fatal(router.Run(":" + port))
|
||
|
|
}
|