Skip to content

Instantly share code, notes, and snippets.

@avescodes
Last active May 9, 2016 07:58
Show Gist options
  • Save avescodes/9980543 to your computer and use it in GitHub Desktop.
Save avescodes/9980543 to your computer and use it in GitHub Desktop.
Minimal Pedestal service without default interceptors or dev tooling machinery. Automatically reloads changes.
(ns my-todo.core
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :refer [router]]
[io.pedestal.http.route.definition :refer [defroutes]]))
(defn hello-world [context]
{:status 200
:body "Hello, world!"
:headers {}})
(defroutes routes
[[["/" {:get hello-world}]]])
(def service {::http/interceptors [(router (fn []
(require 'my-todo.core :reload)
routes))]
::http/port 8080})
(defn -main [& args]
(-> service
http/create-server
http/start))
<!-- Simple Logback configuration for STDOUT-only
Place in resources/logback.xml to quiet down logging output -->
<configuration scan="true" scanPeriod="10 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%-5level %logger{36} - %msg%n</pattern>
</encoder>
<!-- Only log level INFO and above -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
<!-- For loggers in the these namespaces, log at all levels. -->
<logger name="user" level="ALL" />
<logger name="io.pedestal" level="ALL" />
</configuration>
(defproject my-todo "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.6.0"]
[io.pedestal/pedestal.service "0.3.0-SNAPSHOT"]
[io.pedestal/pedestal.service-tools "0.3.0-SNAPSHOT"]
[io.pedestal/pedestal.jetty "0.3.0-SNAPSHOT"]]
:main my-todo.core)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment