scala - how to serve a file within the spray framework (type mismatch getFromFile)? -


this simple question, new scala (and java too). trying implement spray file server. works when returning hello-string, when trying serve file getfromfile get:

error:(16, 24) type mismatch; found   : spray.routing.route (which expands to)  spray.routing.requestcontext => unit  required: spray.httpx.marshalling.toresponsemarshallable         getfromfile("build.sbt")                    ^                         ^   

how should resolve error?

import akka.actor.actorsystem import spray.routing.simpleroutingapp  object main extends simpleroutingapp {   def main(args: array[string]): unit = {     implicit val actorsystem = actorsystem()     startserver(interface="localhost", port = 8080) {         path("file") {           complete {             "hello"             //getfromfile("build.sbt")           }         }     }   } }    

the getfromfile automatically completes request, remove complete , try below. , make sure working directory set such build.sbt in current directory

object main extends simpleroutingapp {   def main(args: array[string]): unit = {     implicit val actorsystem = actorsystem()     startserver(interface="localhost", port = 8080) {         path("file") {             getfromfile("build.sbt")         }     }   } }   

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -