get api working in docker container
This commit is contained in:
parent
ef4f8959df
commit
e18cc26ddd
3 changed files with 16 additions and 11 deletions
|
|
@ -19,6 +19,7 @@ RUN apk add curl rlwrap
|
|||
WORKDIR /app
|
||||
COPY deps.edn ./
|
||||
RUN clj -P
|
||||
RUN clj -Spath
|
||||
COPY build.clj config.edn ./
|
||||
COPY src ./src
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,34 @@
|
|||
(ns micro-blog.api
|
||||
(:require [io.pedestal.connector :as conn]
|
||||
[io.pedestal.http.http-kit :as hk]
|
||||
[micro-blog.config :refer [config]]
|
||||
micro-blog.mastodon
|
||||
micro-blog.blue-sky
|
||||
[taoensso.telemere :as tel]))
|
||||
|
||||
(defn mastodon-proc-handler []
|
||||
(tel/log! :info "Procing Mastodon Scrape")
|
||||
(micro-blog.mastodon/run)
|
||||
{:status 200
|
||||
:body "Scraped Mastodon\n"})
|
||||
(defn mastodon-proc-handler [_request]
|
||||
(let [msg "Proceding Mastodon Scrape"]
|
||||
(tel/log! :info msg)
|
||||
(micro-blog.mastodon/run)
|
||||
{:status 200
|
||||
:body msg}))
|
||||
|
||||
(defn blue-sky-proc-handler []
|
||||
(tel/log! :info "Procing BlueSky Scrape")
|
||||
(defn blue-sky-proc-handler [_request]
|
||||
(let [msg "Procing BlueSky Scrape"]
|
||||
(tel/log! :info msg)
|
||||
(micro-blog.mastodon/run)
|
||||
{:status 200
|
||||
:body "Scraped Mastodon\n"})
|
||||
:body msg}))
|
||||
|
||||
(def routes
|
||||
#{["/bluesky" :get blue-sky-proc-handler :route-name :blue-sky]
|
||||
["/mastodon" :get mastodon-proc-handler :route-name :mastodon]})
|
||||
|
||||
(defn create-connector []
|
||||
(-> (conn/default-connector-map 8890)
|
||||
(-> (conn/default-connector-map (:api-host @config) (Integer/parseInt (str (:api-port @config))))
|
||||
(conn/with-default-interceptors)
|
||||
(conn/with-routes routes)
|
||||
(hk/create-connector nil)))
|
||||
|
||||
(defn start []
|
||||
;; (log/info :in 'start :msg "Starting Pedestal server with Telmere logging")
|
||||
(conn/start! (create-connector)))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
:blue-sky-api-key "BLUE_SKY_API_KEY"
|
||||
:minstral-api-key "MISTRAL_API_KEY"
|
||||
:mastodon-host "MASTODON_BASE_URL"
|
||||
:mastodon-account-id "MASTODON_ACCOUNT_ID"})
|
||||
:mastodon-account-id "MASTODON_ACCOUNT_ID"
|
||||
:api-host "API_HOST"
|
||||
:api-port "API_PORT"})
|
||||
|
||||
(defn- load-config []
|
||||
(merge (read-string (slurp "config.edn"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue