test_helpers.go 699 B

123456789101112131415161718
  1. // Copyright 2012 The Gorilla Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package mux
  5. import "net/http"
  6. // SetURLVars sets the URL variables for the given request, to be accessed via
  7. // mux.Vars for testing route behaviour.
  8. //
  9. // This API should only be used for testing purposes; it provides a way to
  10. // inject variables into the request context. Alternatively, URL variables
  11. // can be set by making a route that captures the required variables,
  12. // starting a server and sending the request to that server.
  13. func SetURLVars(r *http.Request, val map[string]string) *http.Request {
  14. return setVars(r, val)
  15. }