play-filter-only

Utility to apply Play's EssentialFilter to only specific paths

License

License

MIT
GroupId

GroupId

com.github.tkawachi
ArtifactId

ArtifactId

play-filter-only_2.11
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

play-filter-only
Utility to apply Play's EssentialFilter to only specific paths
Project URL

Project URL

https://github.com/tkawachi/play-filter-only/
Project Organization

Project Organization

com.github.tkawachi
Source Code Management

Source Code Management

https://github.com/tkawachi/play-filter-only/

Download play-filter-only_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.tkawachi/play-filter-only_2.11/ -->
<dependency>
    <groupId>com.github.tkawachi</groupId>
    <artifactId>play-filter-only_2.11</artifactId>
    <version>0.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.tkawachi/play-filter-only_2.11/
implementation 'com.github.tkawachi:play-filter-only_2.11:0.3.0'
// https://jarcasting.com/artifacts/com.github.tkawachi/play-filter-only_2.11/
implementation ("com.github.tkawachi:play-filter-only_2.11:0.3.0")
'com.github.tkawachi:play-filter-only_2.11:jar:0.3.0'
<dependency org="com.github.tkawachi" name="play-filter-only_2.11" rev="0.3.0">
  <artifact name="play-filter-only_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.tkawachi', module='play-filter-only_2.11', version='0.3.0')
)
libraryDependencies += "com.github.tkawachi" % "play-filter-only_2.11" % "0.3.0"
[com.github.tkawachi/play-filter-only_2.11 "0.3.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12

provided (1)

Group / Artifact Type Version
com.typesafe.play : play_2.11 jar 2.7.0

Project Modules

There are no modules declared in this project.

play-filter-only

Play's filter is basically applied to all requests. Sometimes I want to apply a filter to only specific paths. PlayFilterOnly wraps a filter, and selectively apply an underlying filter by given predicate.

To use play-filter-only, add a following line to build.sbt (for Play 2.8.x).

libraryDependencies += "com.github.tkawachi" %% "play-filter-only" % "0.4.0"

See the following table if you're using an older version of Play.

Play version Play-filter-only version
2.8.x 0.4.0
2.7.x 0.3.0
2.6.x 0.2.0
2.5.x 0.1.0
2.4.x 0.0.2

For example, to create a CSRFFilter which is only applied to paths starting with /foo.

import com.github.tkawachi.PlayFilterOnly._
CSRFFilter().only(_.path.startsWith("/foo"))

only() takes a function to choose which request to apply a filter.

See http://qiita.com/kawachi/items/1e74647ffe1993b70a62 (Japanese).

This software is released under the MIT License.

Versions

Version
0.3.0
0.2.0
0.1.0
0.0.2
0.0.1