diff options
author | Emile <hanemile@protonmail.com> | 2019-10-18 22:42:32 +0200 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-10-18 22:42:32 +0200 |
commit | 217b6d72f4c1ecb7586ab51ff6fa6c3f010016b2 (patch) | |
tree | e14b0966061eba9c3ddcebb78767918e9ab18ec4 /src/http.go | |
parent | 02e63b59571e356ab36b67c456b88c524241ccc6 (diff) |
basic setup
Diffstat (limited to 'src/http.go')
-rw-r--r-- | src/http.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/http.go b/src/http.go new file mode 100644 index 0000000..a813ae6 --- /dev/null +++ b/src/http.go @@ -0,0 +1,33 @@ +package main + +import ( + "flag" + "fmt" + "net/http" + + "github.com/gorilla/mux" +) + +var ( + port *int +) + +func registerHTTPFlags() { + port = flag.Int("port", 8080, "The port for HTTP") +} + +func setupHTTPServer() http.Server { + r := mux.NewRouter() + + r.HandleFunc("/", indexHandler) + + return http.Server{ + Addr: fmt.Sprintf("0.0.0.0:%d", *port), + Handler: r, + } +} + +// Host the index file +func indexHandler(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "%s", "Hello World!\n") +} |