-
Notifications
You must be signed in to change notification settings - Fork 31
/
main.go
42 lines (37 loc) · 1.01 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
// imports used by the project
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/handlebars"
)
/* renderIndex - renders the index.hbs page
** Input = fiber context
** Output = passes map to layouts/main to be rendered / error
**/
func renderIndex(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{
"Title": "Liam's travel blog!",
"India-Description": "Let's visit India",
"Dubai-Description": "Let's visit Dubai",
"USA-Description": "Let's visit USA",
}, "layouts/main")
}
/* setupRoutes - abstracted function for all application routes
** Input = pointer to fiber App struct
** Output = null
**/
func setupRoutes(app *fiber.App) {
app.Get("/", renderIndex)
}
/* main - main function executing the server and handlebars templating
** Input = null
** Output = null / listens on port 3000 for the app server
**/
func main() {
engine := handlebars.New("./views", ".hbs")
app := fiber.New(fiber.Config{
Views: engine,
})
setupRoutes(app)
app.Listen(":3000")
}