MCPcopy
hub / github.com/gorilla/mux / Test301Redirect

Function Test301Redirect

mux_test.go:1962–1983  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1960}
1961
1962func Test301Redirect(t *testing.T) {
1963 m := make(http.Header)
1964
1965 func1 := func(w http.ResponseWriter, r *http.Request) {}
1966 func2 := func(w http.ResponseWriter, r *http.Request) {}
1967
1968 r := NewRouter()
1969 r.HandleFunc("/api/", func2).Name("func2")
1970 r.HandleFunc("/", func1).Name("func1")
1971
1972 req, _ := http.NewRequest("GET", "http://localhost//api/?abc=def", nil)
1973
1974 res := TestA301ResponseWriter{
1975 hh: m,
1976 status: 0,
1977 }
1978 r.ServeHTTP(&res, req)
1979
1980 if "http://localhost/api/?abc=def" != res.hh["Location"][0] {
1981 t.Errorf("Should have complete URL with query string")
1982 }
1983}
1984
1985func TestSkipClean(t *testing.T) {
1986 func1 := func(w http.ResponseWriter, r *http.Request) {}

Callers

nothing calls this directly

Calls 4

HandleFuncMethod · 0.95
ServeHTTPMethod · 0.95
NewRouterFunction · 0.85
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…