Skip to content

Commit

Permalink
Merge 7028f18 into 7c05140
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilner committed Mar 4, 2019
2 parents 7c05140 + 7028f18 commit b54e4fa
Show file tree
Hide file tree
Showing 9 changed files with 433 additions and 232 deletions.
4 changes: 2 additions & 2 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ func ExampleNew() {
// Output: errored! route 0 "GET /hello/:name": path and handler have different numbers of parameters
}

func ExampleError() {
func ExampleTableError() {
_, err := rte.New(rte.Routes(
"GET /hello", func(w http.ResponseWriter, r *http.Request) {
},
"GET /hello/:name", func(w http.ResponseWriter, r *http.Request, a, b string) {
},
))

_, _ = fmt.Printf("%v", err.(rte.Error).Route)
_, _ = fmt.Printf("%v", err.(*rte.TableError).Route)

// Output: GET /hello/:name
}
Expand Down
6 changes: 3 additions & 3 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func Routes(is ...interface{}) []Route {
r.Method = split[0]
}
}
if _, _, err := funcs.Convert(v); err != nil {
if _, _, ok := funcs.Convert(v); !ok {
panic(fmt.Sprintf(
"rte.Routes: invalid handler for \"%v %v\" in position %v: %v",
"rte.Routes: invalid handler for \"%v %v\" in position %v: %T",
r.Method,
r.Path,
idxHandler,
err,
v,
))
}
r.Handler = v
Expand Down
2 changes: 1 addition & 1 deletion helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func TestRoutes(t *testing.T) {
Args: []interface{}{
"GET /", func() {},
},
PanicVal: "rte.Routes: invalid handler for \"GET /\" in position 1: unknown handler type: func()",
PanicVal: "rte.Routes: invalid handler for \"GET /\" in position 1: func()",
},
{
Name: "prefix shorthand",
Expand Down
9 changes: 4 additions & 5 deletions internal/cmd/rte-gen/tmpl_func.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/cmd/rte-gen/tmpl_tests.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 16 additions & 17 deletions internal/funcs/funcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/funcs/funcs_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b54e4fa

Please sign in to comment.