Skip to content

Instantly share code, notes, and snippets.

@mrubin
mrubin / FrontEndServingController.scala
Last active April 16, 2018 06:56 — forked from themillhousegroup/FrontEndServingController.scala
Play controller for serving a React App out of /public - including front-end routes
package controllers
import java.io.File
import javax.inject.Inject
import play.api.Logger
import play.Environment
import play.api.mvc.{Action, AnyContent}
import play.mvc.Controller
urlencode() {
# urlencode <string>
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c"
esac