Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn get-file-data [file]
- (java.nio.file.Files/readAllBytes
- (Paths/get
- (.toURI (-> (str "public/" file) java.io.File. .getAbsoluteFile)))))
- (defn concat-byte-array [code request file file-extension]
- (byte-array
- (concat
- (.getBytes (add-header code request)) ; add-header makes a string of headers
- (get-file-data (get-file-name file) file-extension)))) ;get-file-data uses the above get-file-data method to create a byte array
- (defn handle-valid-url [request]
- (clojure.java.io/copy (make-binary-response request 200 (get-file-name request) (get-file-extension request)) *out*)) ;make-binary-response just uses the above concat-byte-array to make a concatenated byte array of headers and the body
Advertisement
Add Comment
Please, Sign In to add comment