Skip to content

bug: HandlerFunc does not support HTTP methods in patterns like #897 #899

@angelofallars

Description

@angelofallars

In PR #897, the Mux.Handle method now parses HTTP methods in patterns. However, when I was writing tests for another feature with Mux.HandleFunc that uses pattern HTTP methods, I ran into an error because the feature hasn't been coded in yet for HandleFunc. This has been tested on the latest master branch.

--- FAIL: TestPathValue (0.00s)
    --- FAIL: TestPathValue/Basic_path_value (0.00s)
panic: chi: routing pattern must begin with '/' in 'GET /hubs/{hubID}' [recovered]
        panic: chi: routing pattern must begin with '/' in 'GET /hubs/{hubID}'

goroutine 7 [running]:
testing.tRunner.func1.2({0x6f9aa0, 0xc000030500})
        /usr/lib/go/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
        /usr/lib/go/src/testing/testing.go:1634 +0x377
panic({0x6f9aa0?, 0xc000030500?})
        /usr/lib/go/src/runtime/panic.go:770 +0x132
github.com/go-chi/chi/v5.(*Mux).handle(0x4f61e0?, 0x7672e9?, {0xc00001c270?, 0x7f5a40?}, {0x7f79a0?, 0xc0000304d0?})
        /home/angelo-f/projects/personal/chi/mux.go:405 +0x2c5
github.com/go-chi/chi/v5.(*Mux).HandleFunc(...)
        /home/angelo-f/projects/personal/chi/mux.go:130
github.com/go-chi/chi/v5.TestPathValue.func1(0xc0000ceb60)
        /home/angelo-f/projects/personal/chi/mux_test.go:900 +0x165
testing.tRunner(0xc0000ceb60, 0xc000030490)
        /usr/lib/go/src/testing/testing.go:1689 +0xfb
created by testing.(*T).Run in goroutine 6
        /usr/lib/go/src/testing/testing.go:1742 +0x390
exit status 2
FAIL    github.com/go-chi/chi/v5        0.007s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions