小编Sco*_*ott的帖子

Clojure Pedestal root用作应用程序/八位字节流

我试图在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)

clojure pedestal

6
推荐指数
1
解决办法
358
查看次数

标签 统计

clojure ×1

pedestal ×1