summary refs log tree commit diff stats
path: root/main.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-19 23:45:48 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-20 02:09:20 -0400
commit747f4fb70ff61d3f8a7bb1bed896a913b0999450 (patch)
tree9ed792cbcfba664ebd6d1123f9e7ffdf7fc21105 /main.go
parentf9d8193e1bdce33716b109ac2aea879a8c9b1038 (diff)
downloadgetwtxt-747f4fb70ff61d3f8a7bb1bed896a913b0999450.tar.gz
middleware func to attach remote ip to context
Diffstat (limited to 'main.go')
-rw-r--r--main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.go b/main.go
index 4b62f27..4508edf 100644
--- a/main.go
+++ b/main.go
@@ -66,7 +66,7 @@ func main() {
 	// handlers.CompressHandler gzips all responses.
 	// Write/Read timeouts are self explanatory.
 	server := &http.Server{
-		Handler:      handlers.CompressHandler(index),
+		Handler:      handlers.CompressHandler(ipMiddleware(index)),
 		Addr:         portnum,
 		WriteTimeout: 15 * time.Second,
 		ReadTimeout:  15 * time.Second,
@@ -77,6 +77,12 @@ func main() {
 	if err != nil {
 		log.Printf("%v\n", err)
 	}
+	defer func() {
+		err := server.Close()
+		if err != nil {
+			log.Printf("%v\n", err)
+		}
+	}()
 
 	closelog <- true
 }