Hi all...
I'm an italian mathematician/developer and I'm working on a small tutorial 
on ClojureScript/Clojure.
I'd like to give an insight into client server comunication via the 
shoreleave library and lein ring.
Actually, I'd like to validate a email/password with this simple cljs 
function attached to a login form:

"Client Side"

(ns CLJS-NS
 (:require [shoreleave.remotes.http-rpc :as rpc]))

(defn validate-usr
  [eml pswd]
  (let [regex-mail 
#"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"]
    (if (not (re-matches regex-mail eml))
      (do (js/alert "Please, insert a valid email address.")
          false)
      (rpc/remote-callback :sign-in [eml pswd] #(sign-action %)))))

Meanwhile I defined in a clj ns the following function:

"Server Side"

(ns CLJ-NS
  (:require [cemerick.shoreleave.rpc :refer (defremote)]))

(defremote ^{:remote-name ::sign-in} sign-in
  [eml pswd]
  (let [signing-usr {:email eml :password pswd}]
    (contains? database signing-usr)))

The problem now is how can I make the client see the remote function, as 
the ring server throws a 404 error once i trigger the "login" event. 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to