From 8771f97498c6be5fe95d2eb5fb882c18bbf7f361 Mon Sep 17 00:00:00 2001 From: Franklin Harding <32021905+fharding1@users.noreply.github.com> Date: Sun, 2 Sep 2018 15:22:40 -0700 Subject: [PATCH] Drop support for Go < 1.7: remove gorilla/context (#391) * Drop support for Go < 1.7: remove gorilla/context * Remove Go < 1.7 from Travis CI config * Remove unneeded _native from context files --- .travis.yml | 2 -- context_native.go => context.go | 2 -- context_gorilla.go | 26 --------------- context_gorilla_test.go | 40 ----------------------- context_native_test.go => context_test.go | 2 -- 5 files changed, 72 deletions(-) rename context_native.go => context.go (95%) delete mode 100644 context_gorilla.go delete mode 100644 context_gorilla_test.go rename context_native_test.go => context_test.go (97%) diff --git a/.travis.yml b/.travis.yml index 5da7add..1922f6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ sudo: false matrix: include: - - go: 1.5.x - - go: 1.6.x - go: 1.7.x - go: 1.8.x - go: 1.9.x diff --git a/context_native.go b/context.go similarity index 95% rename from context_native.go rename to context.go index 209cbea..13a4601 100644 --- a/context_native.go +++ b/context.go @@ -1,5 +1,3 @@ -// +build go1.7 - package mux import ( diff --git a/context_gorilla.go b/context_gorilla.go deleted file mode 100644 index d7adaa8..0000000 --- a/context_gorilla.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build !go1.7 - -package mux - -import ( - "net/http" - - "github.com/gorilla/context" -) - -func contextGet(r *http.Request, key interface{}) interface{} { - return context.Get(r, key) -} - -func contextSet(r *http.Request, key, val interface{}) *http.Request { - if val == nil { - return r - } - - context.Set(r, key, val) - return r -} - -func contextClear(r *http.Request) { - context.Clear(r) -} diff --git a/context_gorilla_test.go b/context_gorilla_test.go deleted file mode 100644 index ffaf384..0000000 --- a/context_gorilla_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// +build !go1.7 - -package mux - -import ( - "net/http" - "testing" - - "github.com/gorilla/context" -) - -// Tests that the context is cleared or not cleared properly depending on -// the configuration of the router -func TestKeepContext(t *testing.T) { - func1 := func(w http.ResponseWriter, r *http.Request) {} - - r := NewRouter() - r.HandleFunc("/", func1).Name("func1") - - req, _ := http.NewRequest("GET", "http://localhost/", nil) - context.Set(req, "t", 1) - - res := new(http.ResponseWriter) - r.ServeHTTP(*res, req) - - if _, ok := context.GetOk(req, "t"); ok { - t.Error("Context should have been cleared at end of request") - } - - r.KeepContext = true - - req, _ = http.NewRequest("GET", "http://localhost/", nil) - context.Set(req, "t", 1) - - r.ServeHTTP(*res, req) - if _, ok := context.GetOk(req, "t"); !ok { - t.Error("Context should NOT have been cleared at end of request") - } - -} diff --git a/context_native_test.go b/context_test.go similarity index 97% rename from context_native_test.go rename to context_test.go index c150edf..d8a56b4 100644 --- a/context_native_test.go +++ b/context_test.go @@ -1,5 +1,3 @@ -// +build go1.7 - package mux import (