-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilters.java
More file actions
46 lines (40 loc) · 1.37 KB
/
Filters.java
File metadata and controls
46 lines (40 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import javax.inject.*;
import play.*;
import play.mvc.EssentialFilter;
import play.http.HttpFilters;
import play.mvc.*;
import filters.ExampleFilter;
/**
* This class configures filters that run on every request. This
* class is queried by Play to get a list of filters.
*
* Play will automatically use filters from any class called
* <code>Filters</code> that is placed the root package. You can load filters
* from a different class by adding a `play.http.filters` setting to
* the <code>application.conf</code> configuration file.
*/
@Singleton
public class Filters implements HttpFilters {
private final Environment env;
private final EssentialFilter exampleFilter;
/**
* @param env Basic environment settings for the current application.
* @param exampleFilter A demonstration filter that adds a header to
*/
@Inject
public Filters(Environment env, ExampleFilter exampleFilter) {
this.env = env;
this.exampleFilter = exampleFilter;
}
@Override
public EssentialFilter[] filters() {
// Use the example filter if we're running development mode. If
// we're running in production or test mode then don't use any
// filters at all.
if (env.mode().equals(Mode.DEV)) {
return new EssentialFilter[] { exampleFilter };
} else {
return new EssentialFilter[] {};
}
}
}