Add params

This commit is contained in:
Andros Fenollosa 2020-06-10 20:56:57 +02:00
parent 2ba2a42c2f
commit 5a88d1cd09
2 changed files with 10 additions and 11 deletions

View File

@ -1,13 +1,12 @@
(ns api2smtp.urls
(:require
[compojure.core :refer [defroutes GET]]
[compojure.core :refer [defroutes POST]]
[compojure.route :as route]
[api2smtp.views.public :as view-public]))
(defroutes public
;; Urls public pages
(GET "/" [] view-public/index)
(GET "/api" [] view-public/api))
(POST "/api/v1/email/" [] view-public/index))
(defroutes resources-routes

View File

@ -1,20 +1,20 @@
;;;; Views public web
(ns api2smtp.views.public
(:require
[tadam.templates :refer [render-HTML render-JSON render-404]]
))
[tadam.templates :refer [render-JSON]]
[tadam.responses :refer [response]]))
(defn index
;; View HTML
[req]
(render-HTML req "public/welcome.html" {}))
(let [name (-> :params :name)
subject (-> :params :subject)
email (-> :params :email)
message (-> :params :message)]
(defn api
;; View JSON
[req]
(render-JSON req {:result true}))
(render-JSON req {:status "ok"})))
(defn page-404
;; View page 404
[req]
(render-404 req "public/404.html" {}))
(response req "{\"status\": \"error\"}" 500 "text/json;charset=utf-8"))