iIntroduction fake (NULL) 0 i------------------------------------------------------------ fake (NULL) 0 i fake (NULL) 0 igoophi is a Gopher implementation written in Clojure. It fake (NULL) 0 icomes with the following features: fake (NULL) 0 i fake (NULL) 0 i self-explanatory & powerful routing syntax fake (NULL) 0 i built-in filesystem module fake (NULL) 0 i built-in HTTP redirection module fake (NULL) 0 i Aleph compatibility fake (NULL) 0 i fake (NULL) 0 i fake (NULL) 0 iInstallation fake (NULL) 0 i------------------------------------------------------------ fake (NULL) 0 i fake (NULL) 0 iThis library can be installed from Clojars. fake (NULL) 0 i fake (NULL) 0 i [zcfux/goophi "0.1.3"] fake (NULL) 0 i fake (NULL) 0 i fake (NULL) 0 iQuick overview fake (NULL) 0 i------------------------------------------------------------ fake (NULL) 0 i fake (NULL) 0 iRouting & entities fake (NULL) 0 i------------------ fake (NULL) 0 i fake (NULL) 0 iA Gopher request is represented as a map. It has the fake (NULL) 0 ifollowing keys: fake (NULL) 0 i fake (NULL) 0 i path: selector fake (NULL) 0 i query: search string fake (NULL) 0 i params: parameters found in selector fake (NULL) 0 i remote-addr: remote ip address (added by the Aleph handler) fake (NULL) 0 i fake (NULL) 0 iThe routing module converts a Gopher request to a map & fake (NULL) 0 ievaluates a function returning an entity. fake (NULL) 0 i fake (NULL) 0 i (use 'goophi.core) fake (NULL) 0 i (use 'goophi.routing) fake (NULL) 0 i (use 'goophi.response) fake (NULL) 0 i fake (NULL) 0 i (def hello-world fake (NULL) 0 i (->route fake (NULL) 0 i "*" fake (NULL) 0 i [] fake (NULL) 0 i (menu-entity (info "hello world")))) fake (NULL) 0 i fake (NULL) 0 i (dumps (hello-world "")) fake (NULL) 0 i fake (NULL) 0 i -> ihello world fake (NULL) 0 fake (NULL) 0 i -> . fake (NULL) 0 i fake (NULL) 0 i fake (NULL) 0 ifilesystem module fake (NULL) 0 i----------------- fake (NULL) 0 i fake (NULL) 0 igoophi has a built-in filesystem module with gophermap fake (NULL) 0 isupport. fake (NULL) 0 i fake (NULL) 0 i(use 'goophi.fs) fake (NULL) 0 i fake (NULL) 0 i (def fs-example fake (NULL) 0 i (->route fake (NULL) 0 i "*" fake (NULL) 0 i [:as req] fake (NULL) 0 i (get-contents "./example-pub" (:path req)))) fake (NULL) 0 i fake (NULL) 0 i (dumps (fs-example "docs/hello.txt")) fake (NULL) 0 i fake (NULL) 0 i -> |\__/,| (`\ fake (NULL) 0 i -> _.|o o |_ ) ) fake (NULL) 0 i -> -(((---(((-------- fake (NULL) 0 i -> . fake (NULL) 0 i fake (NULL) 0 iHostname and port are specified in the configuration file fake (NULL) 0 i(config.edn). goophi uses confick for configuration fake (NULL) 0 imanagement. fake (NULL) 0 i fake (NULL) 0 i fake (NULL) 0 iredirection module fake (NULL) 0 i------------------ fake (NULL) 0 i fake (NULL) 0 iURLs are displayed on an HTML redirection page. fake (NULL) 0 i fake (NULL) 0 i (use 'goophi.redirect) fake (NULL) 0 i fake (NULL) 0 i (def redirect-example fake (NULL) 0 i (->route fake (NULL) 0 i "URL\\:*" fake (NULL) 0 i [:as req] fake (NULL) 0 i (if-let [url (selector->url (:path req))] fake (NULL) 0 i (redirect url) fake (NULL) 0 i (menu-entity (info "Not found."))))) fake (NULL) 0 i fake (NULL) 0 i (dumps (redirect-example "URL:https://github.com/20centaurifux/goophi")) fake (NULL) 0 i fake (NULL) 0 i fake (NULL) 0 iTCP fake (NULL) 0 i--- fake (NULL) 0 i fake (NULL) 0 iBuild Aleph compatible request handlers with the tcp module. fake (NULL) 0 i fake (NULL) 0 i (require '[aleph.tcp :as tcp] fake (NULL) 0 i '[goophi.tcp :refer [->gopher-handler]]) fake (NULL) 0 i fake (NULL) 0 i (def my-routes fake (NULL) 0 i (->routes fake (NULL) 0 i ("*" fake (NULL) 0 i [:as req] fake (NULL) 0 i (get-contents "./example-pub" (:path req))))) fake (NULL) 0 i fake (NULL) 0 i (tcp/start-server fake (NULL) 0 i (->gopher-handler my-routes) fake (NULL) 0 i {:port 8070}) fake (NULL) 0 i fake (NULL) 0 i fake (NULL) 0 iMiddleware fake (NULL) 0 i---------- fake (NULL) 0 i fake (NULL) 0 iRead or change the request map by composing a custom request handler. fake (NULL) 0 i fake (NULL) 0 i (defn log-request fake (NULL) 0 i [request] fake (NULL) 0 i (printf "address: %s, path: %s\n" fake (NULL) 0 i (:remote-addr request) fake (NULL) 0 i (:path request)) fake (NULL) 0 i (flush) fake (NULL) 0 i request) ; bypass request map fake (NULL) 0 i fake (NULL) 0 i (def my-app fake (NULL) 0 i (comp fake (NULL) 0 i (->routes fake (NULL) 0 i ("*" fake (NULL) 0 i [:as req] fake (NULL) 0 i (get-contents "./example-pub" (:path req)))) fake (NULL) 0 i log-request)) fake (NULL) 0 i fake (NULL) 0 i (def s (tcp/start-server fake (NULL) 0 i (->gopher-handler my-app) fake (NULL) 0 i {:port 8070})) fake (NULL) 0 i fake (NULL) 0 i fake (NULL) 0 iWWW fake (NULL) 0 i------------------------------------------------------------ fake (NULL) 0 hGithub URL:https://github.com/20centaurifux/goophi/ dixieflatline.de 70 hconfick URL:https://github.com/20centaurifux/confick/ dixieflatline.de 70 hAleph URL:https://github.com/aleph-io/aleph/ dixieflatline.de 70 .