view 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
line wrap: on
line source

package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"
)

func index(rw http.ResponseWriter, req *http.Request) {
	fmt.Fprintln(rw, "I was here!")
}

func main() {
	port := flag.Int("port", 8080, "port to listen at.")
	host := flag.String("host", "localhost", "host to listen at.")
	flag.Parse()

	mux := http.NewServeMux()
	mux.HandleFunc("/", index)

	addr := fmt.Sprintf("%s:%d", *host, *port)
	log.Fatalln(http.ListenAndServe(addr, mux))
}