1
votes

I have a hierarchy as follows

--> myexample.war
  --> WEB-INF
  --> web
    --> admin
      --> index.html
      --> js
        --> somejs.js

What should be my spray route to be able to serve it? (need to use spray).

I tried

  val webRoute = path("web") {
    get {
      entity(as[String]) {
        thePath =>
          complete(getFromResourceDirectory(thePath))
      }
    }
  }

getting:

> error: could not find implicit value for parameter marshaller:
> spray.httpx.marshalling.ToResponseMarshaller[spray.routing.RequestContext
> => Unit]

but it does not seem to be correct, how should I be using it to be able to serve any file from within the web directory?

1

1 Answers

3
votes

Sounds like you are just missing an import statement. Possibly this one:

import spray.httpx.marshalling.Marshaller

Edit

Nevermind. The getFromResourceDirectory doesn't need to be in a complete:

  val webRoute = path("web") {
    get {
      entity(as[String]) {
        thePath =>
          getFromResourceDirectory(thePath)
      }
    }
  }