Running additional WARs in addition to the app #53

Closed
pallix opened this Issue Feb 23, 2012 · 4 comments

2 participants

@pallix

I'm developping a webapp which has two components, one is a JSON REST service, the other the app itself. Both are written in Clojure with Compojure.

When running the app with run-jetty, is there a way to run the service with a specific context path? A simple solution would be to allow additional WARs to be specified and runned by the server. Is it possible?

@pallix

I did something like that but it is rather ugly:

(defn add-war [server contextpath warpath]
  (let [wac (WebAppContext.)]
    (.setWar wac warpath)
    (.setContextPath wac contextpath)
    (.setServer wac server)
    (.addHandler server wac)))

(defn ^Server run-jetty-with-wars
  [handler options wars]
  (let [server (run-jetty handler options)]
    (doseq [w wars]
      (add-war server (:context-path w) (:war-path w)))
    (.stop server)
    (.start server)
    server))
@weavejester
Collaborator

This is more a question than an issue. Please use the Google group for questions; issues should be for bugs and specific feature requests.

@pallix

Ok sorry about that but maybe you can see that as a request for features!

@weavejester
Collaborator

Well, first ask on the group to see if there's an existing solution. For example, if both applications are written in Clojure, you could create a combined handler using the context macro:

(defroutes combined
  (context "/api" [] restful-api)
  (context "/web" [] your-real-app))

However, an issue tracker is not the place to discuss how you'd solve a problem using existing functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment