func (a *application) Init(port int, mode string, f fetcher.Fetcher) {
	// Set gin mode.
	if mode == gin.ReleaseMode {
		gin.SetMode(gin.ReleaseMode)
	} else if mode != gin.DebugMode {
		log.Printf("[WARNING] Invalid application mode provided '%v', "+
			"starting up in default mode '%v'\n", mode, gin.DebugMode)
	}

	// Assign application variables.
	a.port = port
	a.router = gin.Default()
	a.fetcher = f

	// Load and set HTML templates.
	a.router.Static("/public", "public")
	a.router.LoadHTMLGlob("templates/*.html")

	// Define routes.
	a.router.GET("/", a.redirectToIndex)
	a.router.GET("/index", a.index)
	a.router.POST("/index", a.index)
	a.router.GET("/ping", a.ping)
}
// Init is used to initialize an application instance and its router.
// The mode parameter can only be gin.ReleaseMode or gin.DebugMode.
// If an invalid mode is provided, then the default gin.DebugMode
// will be used.
Init is used to initialize an application instance and its router.
The mode parameter can only be gin.ReleaseMode or gin.DebugMode.
If an invalid mode is provided, then the default gin.DebugMode
will be used.
// Init is used to initialize an application instance and its router . // The mode parameter can only be gin . ReleaseMode or gin . DebugMode . // If an invalid mode is provided then the default gin . DebugMode // will be used .
func (a *application) Init(port int, mode string, f fetcher.Fetcher) {
	if mode == gin.ReleaseMode {
		gin.SetMode(gin.ReleaseMode)
	} else if mode != gin.DebugMode {
		log.Printf("[WARNING] Invalid application mode provided '%v', "+
			"starting up in default mode '%v'\n", mode, gin.DebugMode)
	}
	a.port = port
	a.router = gin.Default()
	a.fetcher = f
	a.router.Static("/public", "public")
	a.router.LoadHTMLGlob("templates/*.html")
	a.router.GET("/", a.redirectToIndex)
	a.router.GET("/index", a.index)
	a.router.POST("/index", a.index)
	a.router.GET("/ping", a.ping)
}
func ( a * application ) Init ( port int , mode string , f fetcher . Fetcher ) { if mode == gin . ReleaseMode { gin . SetMode ( gin . ReleaseMode ) } else if mode != gin . DebugMode { log . Printf ( " " + " \n " , mode , gin . DebugMode ) } a . port = port a . router = gin . Default ( ) a . fetcher = f a . router . Static ( " " , " " ) a . router . LoadHTMLGlob ( " " ) a . router . GET ( " " , a . redirectToIndex ) a . router . GET ( " " , a . index ) a . router . POST ( " " , a . index ) a . router . GET ( " " , a . ping ) }
Init is used to initialize an application instance and its router.
Init is used to initialize an application instance and its router .
// Set gin mode. // Assign application variables. // Load and set HTML templates. // Define routes.