服务静态文件与环/ compojure - 从战争 [英] Serving static files with ring/compojure - from a war

查看:118
本文介绍了服务静态文件与环/ compojure - 从战争的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ring(和lein-ring工具) - 我能够从资源等静态文件,当运行在开发中的文档 - 但是 - 当我通过lien uberwar包装我不知道如何使它在容器中运行时为这些文件提供服务。

解决方案

根据Compojure的

a href =https://github.com/weavejester/compojure/wiki/Getting-Started>入门Wiki ,将路线/资源放在您的路径:

 (defroutes main-routes 
(GET/[]< h1> Hello World Wide Web!< / h1>)
(route / resources/)
(route / not-foundPage not found))
/ pre>

...然后,在项目中创建一个文件夹 resources / public 那里。当引用这些文件时, / resources / public 是隐式的,因此你可以写如下:(include-css/ css / site。 css)



这里是示例部署到cloudbees


Using ring (and the lein-ring tools) - I am able to serve up static files from "resources" etc as per the docs when running in development - however - when I package things up via lien uberwar I have no idea how to make it serve those files when running in a container. I see conflicting docs on wrap-resource, or setting :resource-path but none seem to work.

解决方案

As per Compojure's Getting Started Wiki, put route/resources below your paths:

(defroutes main-routes
  (GET "/" [] "<h1>Hello World Wide Web!</h1>")
  (route/resources "/")
  (route/not-found "Page not found"))

...and then, create a folder resources/public in your project, put your static files there. When referring to these files, the /resources/public is implicit, so you can write something like: (include-css "/css/site.css").

Here is an example that deploys to cloudbees.

这篇关于服务静态文件与环/ compojure - 从战争的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆