1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-11 20:40:38 +00:00

adds ability to reset params after a filter runs

When a filter is run _after_ the router completes, it's input params,
such as `":splat"` will have been overwritten by the filter's router pass.
This commit adds the ability to tell the router to revert to the previous input
params after running a filter.
This commit is contained in:
dan pittman
2016-08-05 16:20:56 -07:00
parent 74778bb9d4
commit 0e786fa4af
4 changed files with 117 additions and 14 deletions

View File

@ -301,6 +301,14 @@ func (input *BeegoInput) SetParam(key, val string) {
input.pnames = append(input.pnames, key)
}
// ResetParams clears any of the input's Params
// This function is used to clear parameters so they may be reset between filter
// passes.
func (input *BeegoInput) ResetParams() {
input.pnames = input.pnames[:0]
input.pvalues = input.pvalues[:0]
}
// Query returns input data item string by a given string.
func (input *BeegoInput) Query(key string) string {
if val := input.Param(key); val != "" {