Web Services On Clojure

10 views
Skip to first unread message

Fahed Alrafidi

unread,
Feb 17, 2009, 11:47:07 AM2/17/09
to Clojure
Hello everybody!

How do I create a web service on Clojure? Thank you.

Fahed

James Reeves

unread,
Feb 17, 2009, 3:35:22 PM2/17/09
to Clojure
Fahed Alrafidi wrote:
> How do I create a web service on Clojure? Thank you.

Depends what sort of web service. A simple RESTFUL web service is
pretty easy to develop in Compojure:

(ns web-service
(:use compojure))

(defservlet math-servlet
(POST "/add"
(let [x (Integer/parseInt (params :x))
y (Integer/parseInt (params :y))]
(str (+ x y) "\n"))))

(run-server {:port 8080}
"/math/*" math-servlet)

- James
Reply all
Reply to author
Forward
0 new messages