I am trying to serve static assets with Lagom. I added a play router using additional routers because play has support for serving assets from public folder.
But I can't use Assets.at
function here because it is not static. After compiling code, I also don't see the assets jar, play suppose to create.
public class FileServerRouter implements SimpleRouter {
private final Router delegate;
@Inject
public FileServerRouter(RoutingDsl routingDsl) {
this.delegate =
routingDsl
.GET("/assets/*file")
.routingTo(
(request, file) -> {
// Assets.at(file);
return ok("Serving " + file);
})
.build()
.asScala();
}
@Override
public PartialFunction<RequestHeader, Handler> routes() {
return delegate.routes();
}
}
Does anyone know how to use Assets.at
with RoutingDsl
or any other way to serve static assets with lagom?
question from:
https://stackoverflow.com/questions/65661208/how-to-serve-static-assets-in-lagom 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…