Guest User

Untitled

a guest
May 2nd, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. (defn get-file-data [file]
  2. (java.nio.file.Files/readAllBytes
  3. (Paths/get
  4. (.toURI (-> (str "public/" file) java.io.File. .getAbsoluteFile)))))
  5.  
  6. (defn concat-byte-array [code request file file-extension]
  7. (byte-array
  8. (concat
  9. (.getBytes (add-header code request)) ; add-header makes a string of headers
  10. (get-file-data (get-file-name file) file-extension)))) ;get-file-data uses the above get-file-data method to create a byte array
  11.  
  12. (defn handle-valid-url [request]
  13. (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