Scala Spray Can: how to use a custom server pipeline? -
i starting spray-can web server "io(http) ! http.bind(self)
"; appears spray server hardcoded use default pipeline, hidden away inside io(http)
. i'm using spray 1.3.0
there page in spray related documentation describes server pipeline, , has section "creating pipeline stages" (although looks like).
however, if create custom pipeline stage, how can spray can server use it?
as far can see code, server hardcoded use default pipeline -- in spray.can.server.httplistener
private pipelinestage
val set static call httpserverconnection.pipelinestage
, allows no customisation of standard pipeline setup.
my specific use-case turn on "requestchunkaggregation" urls not others.
i can override pipeline "monkey patching" approach of defining classes same qualified names spray internal classes in codebase , rely on linker load them first, there less hacky way of customising spray can pipeline?
creating pipeline stages http clients simpler in spray 1.2.1. here's how team uses it:
val logrequest: httprequest => httprequest = { r => log.debug(r.tostring); r } val logresponse: httpresponse => httpresponse = { r => log.debug(r.tostring); r } private val defaultpipeline = defaultrequest ~> logrequest ~> sendreceive ~> logresponse def isserveronline: future[boolean] = { val responsefuture = defaultpipeline(get(properties.serveronlineurl)) val serveronline = responsefuture map { response => response.status == statuscodes.ok } serveronline }
Comments
Post a Comment