Turns a handler into a function that takes the same arguments and has the
same return value as the service method in the HttpServlet class.
(defn make-service-method
"Turns a handler into a function that takes the same arguments and has the
same return value as the service method in the HttpServlet class."
[handler]
(fn [#^HttpServlet servlet
#^HttpServletRequest request
#^HttpServletResponse response]
(.setCharacterEncoding response "UTF-8")
(let [request-map (-> request
(build-request-map)
(merge-servlet-keys servlet request response))]
(if-let [response-map (handler request-map)]
(update-servlet-response response response-map)
(throw (NullPointerException. "Handler returned nil"))))))
Comments top
No comments for make-service-method. Log in to add a comment.