Angular akka http+;角2路由
我正在尝试从akka http(scala rest框架)提供angular2(rc3)应用程序。由于路由问题,它无法工作。请求时,spray尝试将Angular akka http+;角2路由,angular,akka-http,Angular,Akka Http,我正在尝试从akka http(scala rest框架)提供angular2(rc3)应用程序。由于路由问题,它无法工作。请求时,spray尝试将/my/endpoint/declared/in/angular作为正常资源查找。我该怎么做 使用简单的静态网页,无需路由(动态链接),非常简单: path("app") { getFromResource("my-app/index.html") } ~ getFromResourceDirectory("my-app") 每次找不到请求的资
/my/endpoint/declared/in/angular
作为正常资源查找。我该怎么做
使用简单的静态网页,无需路由(动态链接),非常简单:
path("app") {
getFromResource("my-app/index.html")
} ~ getFromResourceDirectory("my-app")
每次找不到请求的资源时,我都尝试提供index.html:
path("app") {
getFromResource("my-app/index.html")
} ~ getFromResourceDirectory("my-app") ~ getFromResource("my-app/index.html")
但它破坏了相关链接(当我请求/app/my/endpoint
时,我得到index.html,它试图从/app/my/endpoint/styles.css
而不是/app/styles.css
下载styles.css)
我想知道它是如何在其他http服务器上完成的 我解决了这个问题。它可能不是最优的,但效果相当好 在喷洒配置中,您将:
path("ui") { //the same prefix must be set as base href in index.html
getFromResource("abtest-ui/index.html")
} ~ pathPrefix("ui") {
getFromResourceDirectory("abtest-ui") ~
getFromResource("abtest-ui/index.html")
}
在index.html中:
<base href="/ui/">
总结如下:
- 请求
服务index.html/ui/
- 请求
服务于此资源/ui/someResourceFile.css
- 对
的请求提供index.html并由角度路由处理/ui/anythinghat/IsNotA/ResourceFile