Filterconfig

func FilterConfiguringFilter

func FilterConfiguringFilter(c *Controller, fc []Filter)

FilterConfiguringFilter is a filter stage that customizes the remaining filter chain for the action being invoked.

func FilterEq

func FilterEq(a, b Filter) bool

FilterEq returns true if the two filters reference the same filter.

type FilterConfigurator

type FilterConfigurator struct {
    // contains filtered or unexported fields
}

FilterConfigurator allows the developer configure the filter chain on a per-controller or per-action basis. The filter configuration is applied by the FilterConfiguringFilter, which is itself a filter stage. For example,

Assuming:

Filters = []Filter{
  RouterFilter,
  FilterConfiguringFilter,
  SessionFilter,
  ActionInvoker,
}

Add:

FilterAction(App.Action).
  Add(OtherFilter)

=> RouterFilter, FilterConfiguringFilter, SessionFilter, OtherFilter, ActionInvoker

Remove:

FilterAction(App.Action).
  Remove(SessionFilter)

=> RouterFilter, FilterConfiguringFilter, OtherFilter, ActionInvoker

Insert:

FilterAction(App.Action).
  Insert(OtherFilter, revel.BEFORE, SessionFilter)

=> RouterFilter, FilterConfiguringFilter, OtherFilter, SessionFilter, ActionInvoker

Filter modifications may be combined between Controller and Action. For example:

 FilterController(App{}).
   Add(Filter1)
 FilterAction(App.Action).
   Add(Filter2)

.. would result in App.Action being filtered by both Filter1 and Filter2.

Note: the last filter stage is not subject to the configurator. In particular, Add() adds a filter to the second-to-last place.

func FilterAction

func FilterAction(methodRef interface{}) FilterConfigurator

FilterAction returns a configurator for the filters applied to the given controller method. For example:

FilterAction(MyController.MyAction)

func FilterController

func FilterController(controllerInstance interface{}) FilterConfigurator

FilterController returns a configurator for the filters applied to all actions on the given controller instance. For example:

FilterAction(MyController{})

func (FilterConfigurator) Add

func (conf FilterConfigurator) Add(f Filter) FilterConfigurator

Add the given filter in the second-to-last position in the filter chain. (Second-to-last so that it is before ActionInvoker)

func (FilterConfigurator) Insert

func (conf FilterConfigurator) Insert(insert Filter, where When, target Filter) FilterConfigurator

Insert a filter into the filter chain before or after another. This may be called with the BEFORE or AFTER constants, for example:

revel.FilterAction(App.Index).
  Insert(MyFilter, revel.BEFORE, revel.ActionInvoker).
  Insert(MyFilter2, revel.AFTER, revel.PanicFilter)

func (FilterConfigurator) Remove

func (conf FilterConfigurator) Remove(target Filter) FilterConfigurator

Remove a filter from the filter chain.