Skip to content

Commit 5df5c82

Browse files
beorn7brian-brazil
authored andcommitted
Make route.Param panic on something else than a string (#183)
As discussed in #181, the values in the context should always be strings, but this makes sure of it, while the previous implementation would return an empty string if somehow a non-string value made it into the context. Signed-off-by: Bjoern Rabenstein <[email protected]>
1 parent 3a34257 commit 5df5c82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

route/route.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ type param string
2525
// Param returns param p for the context, or the empty string when
2626
// param does not exist in context.
2727
func Param(ctx context.Context, p string) string {
28-
if v, ok := ctx.Value(param(p)).(string); ok {
29-
return v
28+
if v := ctx.Value(param(p)); v != nil {
29+
return v.(string)
3030
}
3131
return ""
3232
}

0 commit comments

Comments
 (0)