clj

Clojure code posted
created at 01 Jan 00:30

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
(ns xx.views.welcome
  (:require [xx.views.common :as common])
  (use noir.core
       hiccup.core
       hiccup.page-helpers)
  (:use somnium.congomongo)
  (:use [somnium.congomongo.config :only [*mongo-config*]]))

(defn split-mongo-url [url]
  "Parses mongodb url from heroku, eg. mongodb://user:pass@localhost:1234/db"
  (let [matcher (re-matcher #"^.*://(.*?):(.*?)@(.*?):(\d+)/(.*)$" url)] ;; Setup the regex.
    (when (.find matcher) ;; Check if it matches.
      (zipmap [:match :user :pass :host :port :db] (re-groups matcher))))) ;; Construct an options map.
583 Bytes in 2 ms with coderay