Add params
This commit is contained in:
parent
2ba2a42c2f
commit
5a88d1cd09
@ -1,13 +1,12 @@
|
|||||||
(ns api2smtp.urls
|
(ns api2smtp.urls
|
||||||
(:require
|
(:require
|
||||||
[compojure.core :refer [defroutes GET]]
|
[compojure.core :refer [defroutes POST]]
|
||||||
[compojure.route :as route]
|
[compojure.route :as route]
|
||||||
[api2smtp.views.public :as view-public]))
|
[api2smtp.views.public :as view-public]))
|
||||||
|
|
||||||
(defroutes public
|
(defroutes public
|
||||||
;; Urls public pages
|
;; Urls public pages
|
||||||
(GET "/" [] view-public/index)
|
(POST "/api/v1/email/" [] view-public/index))
|
||||||
(GET "/api" [] view-public/api))
|
|
||||||
|
|
||||||
|
|
||||||
(defroutes resources-routes
|
(defroutes resources-routes
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
;;;; Views public web
|
;;;; Views public web
|
||||||
(ns api2smtp.views.public
|
(ns api2smtp.views.public
|
||||||
(:require
|
(:require
|
||||||
[tadam.templates :refer [render-HTML render-JSON render-404]]
|
[tadam.templates :refer [render-JSON]]
|
||||||
))
|
[tadam.responses :refer [response]]))
|
||||||
|
|
||||||
(defn index
|
(defn index
|
||||||
;; View HTML
|
;; View HTML
|
||||||
[req]
|
[req]
|
||||||
(render-HTML req "public/welcome.html" {}))
|
(let [name (-> :params :name)
|
||||||
|
subject (-> :params :subject)
|
||||||
|
email (-> :params :email)
|
||||||
|
message (-> :params :message)]
|
||||||
|
|
||||||
(defn api
|
(render-JSON req {:status "ok"})))
|
||||||
;; View JSON
|
|
||||||
[req]
|
|
||||||
(render-JSON req {:result true}))
|
|
||||||
|
|
||||||
(defn page-404
|
(defn page-404
|
||||||
;; View page 404
|
;; View page 404
|
||||||
[req]
|
[req]
|
||||||
(render-404 req "public/404.html" {}))
|
(response req "{\"status\": \"error\"}" 500 "text/json;charset=utf-8"))
|
||||||
|
Loading…
Reference in New Issue
Block a user