mySitio / cmd / web / main.go
main.go
Raw
package main

import (
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/template/html/v2"
)

var Data *appData //app data can be accessed all throughout application

// Main starts the web application
func main() {
	//initializes the struct that the pointer will reference
	Data = &appData{}

	// Create the template engine
	engine := html.New("./ui/html", ".tmpl")
	engine.Reload(true) // only true for development; reloads templates each render
	// create fiber app
	app := fiber.New(fiber.Config{
		Views:       engine, //template engine set in configuration
		ViewsLayout: "base", // the layout present in all pages base.tmpl
	})

	// designate source of static files
	app.Static("/", "./ui")
	// get main page
	app.Get("/", home)
	app.Get("/projects", projects)

	app.Listen(":8888")
}