-
-
Save joelkuiper/275897ec403752ec2e9a 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
(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