gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/mux/test_helpers.go (about) 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 http "gitee.com/ks-custle/core-gm/gmhttp" 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 }