diff options
Diffstat (limited to 'nix/templates/goapp/frontend/src/main.go')
-rw-r--r-- | nix/templates/goapp/frontend/src/main.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/nix/templates/goapp/frontend/src/main.go b/nix/templates/goapp/frontend/src/main.go new file mode 100644 index 0000000..adb15cd --- /dev/null +++ b/nix/templates/goapp/frontend/src/main.go @@ -0,0 +1,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()) +} |