我试图在Pedestal 0.5.1中托管静态资产和服务.我使用::file-path
指向一个目录来托管文件.如果我直接导航到文件http:// localhost:8888/index.html,这可以正常工作,但如果我转到站点的根目录http:// localhost:8888,它将提供文件application/octet-stream
而不是text/html
.我调整了Hello World Sample并且它具有相同的行为.
SRC /程序hello_world/server.clj
(ns hello-world.server
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route])
(:gen-class))
(def routes
(route/expand-routes [[]]))
(def service
{:env :prod
::http/join? false
::http/routes routes
::http/file-path "/tmp/www"
::http/type :jetty
::http/allowed-origins {:creds true :allowed-origins (constantly true)}
::http/port 8888})
(defonce runnable-service (http/create-server service))
(defn -main
"The entry-point for 'lein run'"
[& args]
(println "\nCreating your server...")
(http/start runnable-service))
Run Code Online (Sandbox Code Playgroud)
开始 lein run
$ curl …
Run Code Online (Sandbox Code Playgroud)