about summary refs log tree commit diff
path: root/nix/templates/goapp/frontend/src/main.go
blob: adb15cd588f897837c29681ea1140b102e7981d7 (plain)
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
package main

import (
	"fmt"
	"log"
	"net/http"
	"time"

	"github.com/gorilla/mux"
)

func indexHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello World from the frontend")
}

func main() {
	r := mux.NewRouter()
	r.HandleFunc("/", indexHandler)

	srv := &http.Server{
		Handler:      r,
		Addr:         ":8080",
		WriteTimeout: 15 * time.Second,
		ReadTimeout:  15 * time.Second,
	}

	log.Printf("[i] Running the server on %s", srv.Addr)
	log.Fatal(srv.ListenAndServe())
}