[Play 2.6 Java] What is the recommended way of adding my own Filters?

(Slisaasquatch) #1

What I’m trying to do is disable all of Play’s default filters and add my own, and I see 2 ways of configuring this.

  1. Disable all of Play’s internal filters with play.filters.enabled = [], and then add my own play.http.HttpFilters implementation with play.http.filters = "com.example.MyFilters" and include com.example.MyFilter inside com.example.MyFilters. This is what this page recommends.
  2. Use play.filters.enabled = ["com.example.MyFilter"] without using play.http.HttpFilters. This is what this page recommends.

They both work. What I’m asking is which is the “definitive” recommended way of doing this.

(Albaro Pereyra) #2

To my understanding when you extend DefaultHttpFilters you are overwriting the defaults. In fact if you want the default filters you have to add them individually.

play.filters.enabled = []
I am sure is for the developer who doesn’t want any filters at all.

There is a subtle difference between the 2.

(Slisaasquatch) #3

You are right about that. I edited my comment.