Vii

Phillip England_

vii

Minimal servers in Go

Installation

1go get github.com/Phillip-England/vii

Hello, World

  1. Create a new go project
  2. Create a ./templates dir
  3. Create a ./static dir

Basic Server:

 1package main
 2
 3import (
 4	"github.com/Phillip-England/vii"
 5)
 6
 7func main() {
 8	app := vii.NewApp()
 9	app.Use(vii.MwLogger, vii.MwTimeout(10))
10	app.Static("./static")
11	app.Favicon()
12	err := app.Templates("./templates", nil)
13	if err != nil {
14		panic(err)
15	}
16  app.At("GET /", func(w http.ResponseWriter, r *http.Request) {
17		vii.ExecuteTemplate(w, r, "index.html", nil)
18	})
19	app.Serve("8080")
20}