| 1510 | } |
| 1511 | |
| 1512 | func TestMuxEmptyParams(t *testing.T) { |
| 1513 | r := NewRouter() |
| 1514 | r.Get(`/users/{x}/{y}/{z}`, func(w http.ResponseWriter, r *http.Request) { |
| 1515 | x := URLParam(r, "x") |
| 1516 | y := URLParam(r, "y") |
| 1517 | z := URLParam(r, "z") |
| 1518 | w.Write([]byte(fmt.Sprintf("%s-%s-%s", x, y, z))) |
| 1519 | }) |
| 1520 | |
| 1521 | ts := httptest.NewServer(r) |
| 1522 | defer ts.Close() |
| 1523 | |
| 1524 | if _, body := testRequest(t, ts, "GET", "/users/a/b/c", nil); body != "a-b-c" { |
| 1525 | t.Fatal(body) |
| 1526 | } |
| 1527 | if _, body := testRequest(t, ts, "GET", "/users///c", nil); body != "--c" { |
| 1528 | t.Fatal(body) |
| 1529 | } |
| 1530 | } |
| 1531 | |
| 1532 | func TestMuxMissingParams(t *testing.T) { |
| 1533 | r := NewRouter() |