From 50757e3feb1e24ac1ac4cc150d0cc7cb56a98cdc Mon Sep 17 00:00:00 2001 From: Tom Andrade Date: Wed, 1 May 2019 08:52:35 +0200 Subject: [PATCH] Improve formating/readability --- main.go | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 48b0f17..662409f 100644 --- a/main.go +++ b/main.go @@ -234,21 +234,31 @@ func main() { r := mux.NewRouter() r.HandleFunc("/", index).Methods("GET") - r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - shortner(w, r, *proto, *domain, hostSuf, *path, *urlSize) - }).Methods("POST") - r.HandleFunc("/{key}", func(w http.ResponseWriter, r *http.Request) { - redirect(w, r, *path) - }).Methods("GET") + + r.HandleFunc("/", + func(w http.ResponseWriter, r *http.Request) { + shortner(w, r, *proto, *domain, hostSuf, *path, *urlSize) + }).Methods("POST") + + r.HandleFunc("/{key}", + func(w http.ResponseWriter, r *http.Request) { + redirect(w, r, *path) + }).Methods("GET") + + r.HandleFunc("/v1/dumpToFile", + func(w http.ResponseWriter, r *http.Request) { + itemsDumpToFile(w, r, *dumpFile) + }).Methods("GET") + + r.HandleFunc("/v1/fromFile", + func(w http.ResponseWriter, r *http.Request) { + itemsFromFile(w, r, *dumpFile) + }).Methods("GET") + r.HandleFunc("/v1/count", itemsCount).Methods("GET") r.HandleFunc("/v1/dump", itemsDump).Methods("GET") - r.HandleFunc("/v1/dumpToFile", func(w http.ResponseWriter, r *http.Request) { - itemsDumpToFile(w, r, *dumpFile) - }).Methods("GET") - r.HandleFunc("/v1/fromFile", func(w http.ResponseWriter, r *http.Request) { - itemsFromFile(w, r, *dumpFile) - }).Methods("GET") r.HandleFunc("/v1/fromPost", itemsFromPost).Methods("POST") + log.Printf("Domain: %s, URL Proto: %s, Listen Address: %s\n", *domain, *proto, *addr) log.Fatal(http.ListenAndServe(listenAddr, handlers.CombinedLoggingHandler(os.Stdout, r))) }