Ejemplo n.º 1
0
func StartGin() {
	gin.SetMode(gin.ReleaseMode)

	router := gin.New()
	router.Use(rateLimit, gin.Recovery())
	router.LoadHTMLGlob("resources/*.templ.html")
	router.Static("/static", "resources/static")
	router.GET("/", index)
	router.GET("/room/:roomid", roomGET)
	router.POST("/room-post/:roomid", roomPOST)
	router.GET("/stream/:roomid", streamRoom)

	router.Run(":80")
}
Ejemplo n.º 2
0
// This function's name is a must. App Engine uses it to drive the requests properly.
func init() {
	// Starts a new Gin instance with no middle-ware
	r := gin.New()

	// Define your handlers
	r.GET("/", func(c *gin.Context) {
		c.String(200, "Hello World!")
	})
	r.GET("/ping", func(c *gin.Context) {
		c.String(200, "pong")
	})

	// Handle all requests using net/http
	http.Handle("/", r)
}
Ejemplo n.º 3
0
func main() {
	fmt.Println("Starting hotseats-api...")

	router := gin.New()

	// Configure middleware to be used
	router.Use(gin.Logger())

	// Route definitions
	router.GET("/status", statusHandler)
	router.GET("/events/:stadium", handlers.ListEvents)

	router.POST("/events", handlers.CreateEvent)

	port := os.Getenv("PORT")

	fmt.Println("Listening on port ", port)
	router.Run(":" + port)
}