comparison cmd/tokenserver/main.go @ 15:05d828374256

Reverted to previous setup of /api prefixing only the token route At present it seems best only to prefix the token route if we are planning to serve static files from a web folder
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 21 Jun 2018 09:20:39 +0200
parents afc0de09231f
children a98a282f00e1
comparison
equal deleted inserted replaced
14:afc0de09231f 15:05d828374256
43 host := flag.String("host", "localhost", "host to listen at.") 43 host := flag.String("host", "localhost", "host to listen at.")
44 flag.Parse() 44 flag.Parse()
45 p, _ := filepath.Abs("./web") 45 p, _ := filepath.Abs("./web")
46 mux := http.NewServeMux() 46 mux := http.NewServeMux()
47 mux.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(p)))) 47 mux.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(p))))
48 mux.HandleFunc("/token", token) 48 mux.HandleFunc("/api/token", token)
49 api := http.NewServeMux()
50 api.Handle("/api/", http.StripPrefix("/api", mux))
51 49
52 addr := fmt.Sprintf("%s:%d", *host, *port) 50 addr := fmt.Sprintf("%s:%d", *host, *port)
53 log.Fatalln(http.ListenAndServe(addr, api)) 51 log.Fatalln(http.ListenAndServe(addr, mux))
54 } 52 }