blob: 5f5c496de0129816966873f31cce8b41c76668fe [file] [log] [blame]
Matteo Scandoloa4285862020-12-01 18:10:10 -08001// 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
5package mux
6
7import "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.
17func SetURLVars(r *http.Request, val map[string]string) *http.Request {
18 return requestWithVars(r, val)
19}