Skip to content

Commit

Permalink
Filters: Use funcs instead of vars.
Browse files Browse the repository at this point in the history
  • Loading branch information
robfig committed Jun 6, 2013
1 parent ef5552f commit 04a00b6
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion filterconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func FilterEq(a, b Filter) bool {

// FilterConfiguringFilter is a filter stage that customizes the remaining
// filter chain for the action being invoked.
var FilterConfiguringFilter = func(c *Controller, fc []Filter) {
func FilterConfiguringFilter(c *Controller, fc []Filter) {
if newChain := getOverrideChain(c.Name, c.Action); newChain != nil {
newChain[0](c, newChain[1:])
return
Expand Down
2 changes: 1 addition & 1 deletion flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (f Flash) Success(msg string, args ...interface{}) {
}
}

var FlashFilter = func(c *Controller, fc []Filter) {
func FlashFilter(c *Controller, fc []Filter) {
c.Flash = restoreFlash(c.Request.Request)
c.RenderArgs["flash"] = c.Flash.Data

Expand Down
2 changes: 1 addition & 1 deletion i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func init() {
})
}

var I18nFilter = func(c *Controller, fc []Filter) {
func I18nFilter(c *Controller, fc []Filter) {
if foundCookie, cookieValue := hasLocaleCookie(c.Request); foundCookie {
TRACE.Printf("Found locale cookie value: %s", cookieValue)
setCurrentLocaleControllerArguments(c, cookieValue)
Expand Down
2 changes: 1 addition & 1 deletion intercept.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (i Interception) Invoke(val reflect.Value) reflect.Value {
return vals[0]
}

var InterceptorFilter = func(c *Controller, fc []Filter) {
func InterceptorFilter(c *Controller, fc []Filter) {
defer invokeInterceptors(FINALLY, c)
defer func() {
if err := recover(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var (
websocketType = reflect.TypeOf((*websocket.Conn)(nil))
)

var ActionInvoker = func(c *Controller, _ []Filter) {
func ActionInvoker(c *Controller, _ []Filter) {
// Instantiate the method.
methodValue := reflect.ValueOf(c.AppController).MethodByName(c.MethodType.Name)

Expand Down
2 changes: 1 addition & 1 deletion panic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

// PanicFilter wraps the action invocation in a protective defer blanket that
// converts panics into 500 error pages.
var PanicFilter = func(c *Controller, fc []Filter) {
func PanicFilter(c *Controller, fc []Filter) {
defer func() {
if err := recover(); err != nil {
handleInvocationPanic(c, err)
Expand Down
2 changes: 1 addition & 1 deletion params.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (p *Params) calcValues() url.Values {
return values
}

var ParamsFilter = func(c *Controller, fc []Filter) {
func ParamsFilter(c *Controller, fc []Filter) {
ParseParams(c.Params, c.Request)

// Clean up from the request.
Expand Down
2 changes: 1 addition & 1 deletion router.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func init() {
})
}

var RouterFilter = func(c *Controller, fc []Filter) {
func RouterFilter(c *Controller, fc []Filter) {
// Figure out the Controller/Action
var route *RouteMatch = MainRouter.Route(c.Request.Request)
if route == nil {
Expand Down
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func getSessionFromCookie(cookie *http.Cookie) Session {
return session
}

var SessionFilter = func(c *Controller, fc []Filter) {
func SessionFilter(c *Controller, fc []Filter) {
c.Session = restoreSession(c.Request.Request)

fc[0](c, fc[1:])
Expand Down
2 changes: 1 addition & 1 deletion validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (v *Validation) Check(obj interface{}, checks ...Validator) *ValidationResu
return result
}

var ValidationFilter = func(c *Controller, fc []Filter) {
func ValidationFilter(c *Controller, fc []Filter) {
c.Validation = &Validation{
Errors: restoreValidationErrors(c.Request.Request),
keep: false,
Expand Down

0 comments on commit 04a00b6

Please sign in to comment.