I've made simplest Pedestal project and run it in my repl locally. However, after checking browser at localhost:8890
I saw � (replacement characters) instead of actual text (cyrillic symbols) I put in my Pedestal route.
I also checked in browser devtools response headers: Content-Type:text/html;charset=utf-8 is present.
Before you ask:
charset=UTF-8
in response, as you can see in code below.core.clj
file is also in UTF-8 encoding.The whole code of project:
(ns samplepedestal.core
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route])
(:gen-class))
(defn html-response
[req]
{:status 200
:body "<html lang=\"ru\">
<head>
<meta charset=\"utf-8\" />
<title>Текст на русском</title>
</head>
<body>Текст на русском</body>
</html>"
:headers {"Content-Type" "text/html; charset=UTF-8"}})
(def routes
(route/expand-routes
[[["/" {:get `html-response}]]]))
(def service-map
{::http/routes routes
::http/type :jetty
::http/port 8890})
(defn start []
(http/start (http/create-server service-map)))
;; -- Interactive development
(defonce server (atom nil))
(defn start-dev []
(reset! server
(http/start (http/create-server
(assoc service-map
::http/join? false)))))
(defn stop-dev []
(http/stop @server))
(defn restart []
(stop-dev)
(start-dev))
;; ---
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
This is kind of strange behaviour, I have no clue what I'm missing, so any help would be appreciated. Thanks!
I think the problem is in how REPL starts. Have you got something along the lines of
Starting nREPL server... "C:\Program Files\Java\jdk1.8.0_66\jre\bin\java" -Dfile.encoding=Cp1251 -XX:-OmitStackTraceInFastThrow -Dclojure.compile.path=D:\workspace-clojure\the-next-big-server-side-thing\target\classes -Dthe-next-big-server-side-thing.version=0.0.1-SNAPSHOT -Dclojure.debug=false -Didea.launcher.port=50071 "-Didea.launcher.bin.
when REPL starts?
If so, you might want to add new JVM parameter to fix that.