If you use spray routing then this should be easy, just specify a route for your static resources. For example, you can do the following:
Say your static resources are in the /css , /js and /img folders:
def staticPrefixes = List("css", "js", "img") map { pathPrefix(_) } reduce { _ | _ }
with pathPrefix you make each path the prefix of an unsurpassed path. Then you need a directive to extract the path to the static file from the request, for example, you can do it like this:
def stripLeadingSlash(path: String) = if (path startsWith "/") path.tail else path val staticPath = staticPrefixes & cache(routeCache()) & extract(ctx β stripLeadingSlash(ctx.request.uri.path.toString))
then create your route that will manage your resources:
val staticRoutes = get { staticPath { path β getFromResource(path.toString) } }
source share