Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 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 | |
| 5 | package mux |
| 6 | |
| 7 | import "net/http" |
| 8 | |
| 9 | // SetURLVars sets the URL variables for the given request, to be accessed via |
| 10 | // mux.Vars for testing route behaviour. Arguments are not modified, a shallow |
| 11 | // copy is returned. |
| 12 | // |
| 13 | // This API should only be used for testing purposes; it provides a way to |
| 14 | // inject variables into the request context. Alternatively, URL variables |
| 15 | // can be set by making a route that captures the required variables, |
| 16 | // starting a server and sending the request to that server. |
| 17 | func SetURLVars(r *http.Request, val map[string]string) *http.Request { |
| 18 | return requestWithVars(r, val) |
| 19 | } |