Skip to content

Commit

Permalink
export Params field (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
2hmad authored Apr 13, 2023
1 parent 49dea4f commit 89d63b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type handlerFunc func(ctx *Context) error

type Context struct {
RequestCtx *fasthttp.RequestCtx
params map[string]string
Params map[string]string
paramValues []string
handlers []handlerFunc
handlerIdx int
Expand All @@ -36,7 +36,7 @@ type Cookie struct {
func NewContext(ctx *fasthttp.RequestCtx, params map[string]string) *Context {
return &Context{
RequestCtx: ctx,
params: params,
Params: params,
paramValues: make([]string, 0, 10),
handlers: nil,
handlerIdx: -1,
Expand All @@ -50,13 +50,13 @@ func (c *Context) Context() *fasthttp.RequestCtx {

// WithParams sets the params for the context.
func (c *Context) WithParams(params map[string]string) *Context {
c.params = params
c.Params = params
return c
}

// Param returns the param value for the given key.
func (c *Context) Param(key string) string {
return c.params[key]
return c.Params[key]
}

// Query returns the query value for the given key.
Expand Down
2 changes: 1 addition & 1 deletion router.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (r *Router) find(method, path string) []Handler {
for _, route := range routes {
if matches, params := route.match(path); matches {
c := NewContext(nil, nil)
c.params = params
c.Params = params
return r.applyMiddleware(route.Handlers, method)
}
}
Expand Down

0 comments on commit 89d63b7

Please sign in to comment.