Ejemplo n.º 1
0
func main() {
	env = NewEnv()
	defer env.db.session.Close()

	// Creates a gin router with default middlewares:
	// logger and recovery (crash-free) middlewares
	// router := gin.Default()
	// Recovery returns a middleware that recovers from any panics and writes
	// a 500 if there was one.
	router := gin.New()
	router.Use(gin.Recovery())
	router.Use(gin.Logger())
	router.LoadHTMLGlob("templates/*.tmpl.html")
	router.Static("/static", "static")

	router.GET("/", indexFunc)

	router.GET("/mark", mdFunc)

	dict := router.Group("/dictionary")
	{
		dict.GET("/db", dbFunc)
	}

	router.Run(":" + env.port)
}
Ejemplo n.º 2
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")
}