Created
June 18, 2015 13:17
-
-
Save lancewalton/aa2811e0823ffaf93387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Document(id: String, contentType: String, content: Array[Byte]) | |
object Server { | |
def apply() = { | |
val service = HttpService { | |
case req @ POST -> Root / "document" / id => upload(req, id) | |
} | |
JettyBuilder | |
.bindHttp(8080) | |
.mountService(service, "/") | |
} | |
private def upload(req: Request, id: String) = { | |
// I want to do something here that results in a call to store(document) | |
// document.id is given by the id parameter | |
// document.contentType is given by req.contentType and it is required | |
// document.content is given by the request body | |
} | |
private def store(document: Document) = { | |
// Side effecting stuff that writes the document somewhere | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment