Created
December 6, 2012 13:35
-
-
Save yuanmai/4224484 to your computer and use it in GitHub Desktop.
Ring Hello
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
(defn app [req] | |
{:status 200 | |
:headers {"Content-Type" "text/html"} | |
:body (str "Hi from " (:server-name req))}) | |
(use 'ring.adapter.jetty) | |
(run-jetty app {:port 8080}) |
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
import javax.servlet.http.*; | |
import javax.servlet.*; | |
public class HelloServlet extends HttpServlet { | |
public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | |
res.setStatus(200); | |
res.setContentType("text/plain"); | |
PrintWriter out = res.getWriter(); | |
out.println("Hello world"); | |
out.close(); | |
} | |
} |
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
user> (app {:server-name "localhost"}) | |
{:status 200, :headers {"Content-Type" "text/html"}, :body "Hi from localhost"} | |
user> (= {:status 200, :headers {"Content-Type" "text/html"}, :body "Hi from localhost"} (app {:server-name "localhost"})) | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment