Skip to content

Instantly share code, notes, and snippets.

@c-garcia
Last active December 2, 2015 22:23
Show Gist options
  • Save c-garcia/45cf61eb3bd21d8f2706 to your computer and use it in GitHub Desktop.
Save c-garcia/45cf61eb3bd21d8f2706 to your computer and use it in GitHub Desktop.
Receives an HTTP request (a ring-map) and decides if it needs to forward the request to the real server or if it can do it by itself with the data it already has (cache).
(defn process-request
"The heart of the Application Gateway. Checks if word is not _forbidden_ or
_cached_ and if is not the case, it forwards the request to the orignal
server."
[word]
(debug "Received request for word" word)
(cond
(forbidden? word) (forbidden-response word)
(cached? word) (cached-response word)
:else (forward-request-and-cache! word (env :forward-port))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment