Skip to content

Instantly share code, notes, and snippets.

@nantsou
Created March 10, 2019 03:20
Show Gist options
  • Save nantsou/7a9d9aab9914cd2cff7f74762c13b9a4 to your computer and use it in GitHub Desktop.
Save nantsou/7a9d9aab9914cd2cff7f74762c13b9a4 to your computer and use it in GitHub Desktop.
type MockRouter struct {
mu sync.Mutex
r *mux.Router
}
func (mr *MockRouter) Swap(r *mux.Router) {
mr.mu.Lock()
mr.r = r
mr.mu.Unlock()
}
func (mr *MockRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
mr.r.ServeHTTP(w, r)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment