Skip to content

Instantly share code, notes, and snippets.

@joelkuiper
Last active December 4, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelkuiper/275897ec403752ec2e9a to your computer and use it in GitHub Desktop.
Save joelkuiper/275897ec403752ec2e9a to your computer and use it in GitHub Desktop.
(defn process-documents
[req matcher]
(let [resp (chan)
handler (fn [req]
(let [params (:multipart-params req)
body {:documents (pdf/as-documents (get params "upload-file"))
:tuis (str/split (get params "tuis") #",")}]
(ok (coerce! dm/AnnotateResponse (dm/match matcher body)))))]
(go
(>! resp ((wrap-formats handler) req)))
(async req resp)))
(defapi service-routes
(ring.swagger.ui/swagger-ui "/swagger-ui")
;; JSON docs available at the /swagger.json route
(swagger-docs {:info {:title "DataHub API"}})
(context*
"/api" []
(POST* "/annotateDocuments" req
:components [matcher]
:middlewares [wrap-multipart-params]
:summary "Provided PDF files, will run the list of matched concepts and their annotations."
:swagger {:responses {200 {:description "valid annotations"
:schema dm/AnnotateResponse}}}
;;:return dm/AnnotateResponse
(process-documents req matcher)) ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment