A game framework route that matches all

I am working on an angular application using a playback platform for my leisure services. Everything in the shared folder is an angular application (style sheets, javascripts, images and html). I want every request that is not for something in style sheets, javascripts, templates or images to be sent to the index.html page. This means that angular routing can take over from there ...

As a note, I can mention that I am going to place every rests service under /services/, which communicates with my own java controllers.

Is it possible in framework 2.3.4 to define a route that will catch everyone without using the appropriate elements?

This is my defs route so far:

GET     /                       controllers.Assets.at(path="/public", file="index.html")
GET     /stylesheets/*file      controllers.Assets.at(path="/public/stylesheets", file)
GET     /javascripts/*file      controllers.Assets.at(path="/public/javascripts", file)
GET     /templates/*file        controllers.Assets.at(path="/public/templates", file)
GET     /images/*file           controllers.Assets.at(path="/public/images", file)

#this line fails
GET     /*                      controllers.Assets.at(path="/public", file="index.html")
+4
2

, . :

GET         /*path               controllers.Application.matchAll(path)

:

public class Application extends Controller {

    public static Result matchAll(String path) {
        return redirect(controllers.routes.Assets.at("index.html"));
    }

}

, . MIME- .

public class Application extends Controller {

    public static Result matchAll(String path) {
        return ok(Application.class.getResourceAsStream("/public/index.html")).as("text/html");
    }

}
+3

onHandlerNotFound Global class, :

import play.*;
import play.mvc.*;
import play.mvc.Http.*;
import play.libs.F.*;

import static play.mvc.Results.*;

public class Global extends GlobalSettings {

    public Promise<Result> onHandlerNotFound(RequestHeader request) {
        return Promise.<Result>pure(notFound(
            views.html.notFoundPage.render(request.uri())
        ));
    }

}
0

All Articles