github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/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 "github.com/hxx258456/ccgo/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 }