comparison cmd/tokenserver/main.go @ 1:0e1d0c00bc74

Useless webserver to test go-gettablity.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 11 Jun 2018 11:53:07 +0200
parents
children 9c6f68a8e8b2
comparison
equal deleted inserted replaced
0:f771210e4484 1:0e1d0c00bc74
1 package main
2
3 import (
4 "flag"
5 "fmt"
6 "log"
7 "net/http"
8 )
9
10 func index(rw http.ResponseWriter, req *http.Request) {
11 fmt.Fprintln(rw, "I was here!")
12 }
13
14 func main() {
15 port := flag.Int("port", 8080, "port to listen at.")
16 host := flag.String("host", "localhost", "host to listen at.")
17 flag.Parse()
18
19 mux := http.NewServeMux()
20 mux.HandleFunc("/", index)
21
22 addr := fmt.Sprintf("%s:%d", *host, *port)
23 log.Fatalln(http.ListenAndServe(addr, mux))
24 }