(t *testing.T)
| 527 | } |
| 528 | |
| 529 | func TestCORSMethodMiddlewareSubrouter(t *testing.T) { |
| 530 | router := NewRouter().StrictSlash(true) |
| 531 | |
| 532 | subrouter := router.PathPrefix("/test").Subrouter() |
| 533 | subrouter.HandleFunc("/hello", stringHandler("a")).Methods(http.MethodGet, http.MethodOptions, http.MethodPost) |
| 534 | subrouter.HandleFunc("/hello/{name}", stringHandler("b")).Methods(http.MethodGet, http.MethodOptions) |
| 535 | |
| 536 | subrouter.Use(CORSMethodMiddleware(subrouter)) |
| 537 | |
| 538 | rw := NewRecorder() |
| 539 | req := newRequest("GET", "/test/hello/asdf") |
| 540 | router.ServeHTTP(rw, req) |
| 541 | |
| 542 | actualMethods := rw.Header().Get("Access-Control-Allow-Methods") |
| 543 | expectedMethods := "GET,OPTIONS" |
| 544 | if actualMethods != expectedMethods { |
| 545 | t.Fatalf("expected methods %q but got: %q", expectedMethods, actualMethods) |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | func TestMiddlewareOnMultiSubrouter(t *testing.T) { |
| 550 | first := "first" |
nothing calls this directly
no test coverage detected