Created
December 31, 2012 19:45
-
-
Save anonymous/4422217 to your computer and use it in GitHub Desktop.
Fingure: hyper-minimal finger server in Clojure.
This file contains hidden or 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
(ns fingure.core | |
(:gen-class)) | |
(use 'lamina.core 'aleph.tcp 'gloss.core) | |
(defn response [query] | |
(println (count query)) | |
(if (clojure.string/blank? query) | |
"Greetings from the fingure finger daemon." | |
(str "Greetings from the fingure finger daemon.\r\nNo information about " query " found."))) | |
(defn handler [ch client-info] | |
(receive-all ch | |
#(enqueue-and-close ch (response %)))) | |
(defn -main[] | |
(start-tcp-server handler {:port 79, :frame (string :utf-8 :delimiters ["\r\n"])})) |
This file contains hidden or 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
$ finger @localhost | |
[localhost] | |
Trying 127.0.0.1... | |
Greetings from the fingure finger daemon. | |
$ finger foo@localhost | |
[localhost] | |
Trying 127.0.0.1... | |
Greetings from the fingure finger daemon. | |
No information about foo found. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment