Application has to use servlets instead of filters, how to adapt?

14 views
Skip to first unread message

Dominykas Mostauskis

unread,
Oct 19, 2015, 10:43:43 AM10/19/15
to Unfiltered
Due to limitations of Google App Engine's development server, I cannot use servlet filters. I asked for advice in the issues section, and would like a bit more assistance.

Chris pointed out that to use servlets with Unfiltered would put limitations on the library. To my understanding that means that if a Plan fails to pattern match a request, it cannot pass on the servicing to another plan? Or not through the unfiltered.response.Pass mechanism. Am I correct? Are there other gotchas?

He also advised against using servlets with unfiltered pointing out that there are workarounds to the issues I am facing; however, I have found that there are no (other) workarounds.

As to the actual implementation of a crippled Unfiltered Plan on servlets:
 trait Plan extends /*InittedFilter*/ InittedServlet {
   
def intent: Plan.Intent
   
def /*doFilter*/ service(request: ServletRequest,
     response
: ServletResponse,
     
//chain: FilterChain
     
) {
     
(request, response) match {
       
case (hreq: HttpServletRequest, hres: HttpServletResponse) =>
         val request
= new RequestBinding(hreq)
         val response
= new ResponseBinding(hres)
         
/*Pass.fold(
           intent,
           (_: HttpRequest[HttpServletRequest]) =>
             chain.doFilter(request.underlying, response.underlying),
           (_: HttpRequest[HttpServletRequest],
             rf: ResponseFunction[HttpServletResponse]) => {
               val res = rf(response)
               res.outputStream.close()
           }
         )(request)*/

         val rf
= intent(request)
         val res
= rf(response)
         res
.outputStream.close()
       }
   
}
 
}

That's how I imagine a Plan on servlets. Above I took the current implementation of Plan and added lines/commented out thing. Did I overlook anything? Do you have comments?
Reply all
Reply to author
Forward
0 new messages