My routes are defined as follows
(defroutes main-routes
(wrap-json (GET "/services/location/actions/List/invocation" []
req/availability))
(route/resources "/app" {:root "public/app"})
(GET "/*" [] (resource-response "index.html" {:root "public/app"})))
What I am trying to do is build a single page application. The client connects to a url http://localhost/app/index.html and is shown the index page. The client can navigate back and forth in the single page api successfully. For now the non source resources are in a directory called app, under resources/public. I am using the pushstate api and angularjs on the client side. When there is a page refresh I want to send the client back to index page - else they will receive a page not found error. How do I do it? The above gives me the following error
java.lang.IndexOutOfBoundsException
RT.java:784 clojure.lang.RT.nthFrom RT.java:753 clojure.lang.RT.nth utils.clj:52 clj-stacktrace.utils/quartile1 utils.clj:69 clj-stacktrace.utils/fence repl.clj:98 clj-stacktrace.repl/find-source-width repl.clj:107 clj-stacktrace.repl/pst-on repl.clj:123 clj-stacktrace.repl/pst-str RestFn.java:408 clojure.lang.RestFn.invoke stacktrace.clj:17 ring.middleware.stacktrace/wrap-stacktrace-log[fn] stacktrace.clj:79 ring.middleware.stacktrace/wrap-stacktrace-web[fn] reload.clj:18 ring.middleware.reload/wrap-reload[fn] jetty.clj:18 ring.adapter.jetty/proxy-handler[fn] (Unknown Source) ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle HandlerWrapper.java:111 org.eclipse.jetty.server.handler.HandlerWrapper.handle Server.java:349 org.eclipse.jetty.server.Server.handle AbstractHttpConnection.java:452 org.eclipse.jetty.server.AbstractHttpConnection.handleRequest AbstractHttpConnection.java:884 org.eclipse.jetty.server.AbstractHttpConnection.headerComplete AbstractHttpConnection.java:938 org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete HttpParser.java:634 org.eclipse.jetty.http.HttpParser.parseNext HttpParser.java:230 org.eclipse.jetty.http.HttpParser.parseAvailable AsyncHttpConnection.java:76 org.eclipse.jetty.server.AsyncHttpConnection.handle SelectChannelEndPoint.java:609 org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle SelectChannelEndPoint.java:45 org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run QueuedThreadPool.java:599 org.eclipse.jetty.util.thread.QueuedThreadPool.runJob QueuedThreadPool.java:534 org.eclipse.jetty.util.thread.QueuedThreadPool$3.run Thread.java:722 java.lang.Thread.run
I am using clojure 1.4, compojure 1.1.3 and ring 1.1.6.
I get a similar exception when I try to return the index.html file as a file-response.
Thank you
Sid
P.s: James, this is a followup to the post on the lein group you had responded to yesterday.
--
You received this message because you are subscribed to the Google Groups "Compojure" group.
To view this discussion on the web visit https://groups.google.com/d/msg/compojure/-/HI2NtAgzAo4J.
To post to this group, send email to comp...@googlegroups.com.
To unsubscribe from this group, send email to compojure+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/compojure?hl=en.
| Matcher.java:1234 | java.util.regex.Matcher.getTextLength |
| Matcher.java:308 | java.util.regex.Matcher.reset |
| Matcher.java:228 | java.util.regex.Matcher.<init> |
| Pattern.java:1088 | java.util.regex.Pattern.matcher |
| core.clj:4286 | clojure.core/re-matcher |
| core.clj:4338 | clojure.core/re-find |
| refresh.clj:18 | ring.middleware.refresh/html-content? |
| refresh.clj:84 | ring.middleware.refresh/wrap-with-script[fn] |
| core.clj:106 | compojure.core/routing[fn] |
| core.clj:2390 | clojure.core/some |
| core.clj:106 | compojure.core/routing |
| RestFn.java:139 | clojure.lang.RestFn.applyTo |
| core.clj:603 | clojure.core/apply |
| core.clj:111 | compojure.core/routes[fn] |
| params.clj:55 | ring.middleware.params/wrap-params[fn] |
| stacktrace.clj:15 | ring.middleware.stacktrace/wrap-stacktrace-log[fn] |
To view this discussion on the web visit https://groups.google.com/d/msg/compojure/-/0nwTrqjGFHoJ.
Forgot to add that if I comment out the final route i.e.
(GET "/*" [] (resource-response "index.html" {:root "public/app"} the errors go away. The intended behaviour is still missing.
To view this discussion on the web visit https://groups.google.com/d/msg/compojure/-/CByt8tNSeaAJ.