I'm developing a relatively simple web app using play framework for the server and dart for the client. I'm using eclipse. Development and debug are fine on their own but how do to get them to work together?
我正在开发一个相对简单的Web应用程序,使用服务器的播放框架和客户端的dart。我正在使用eclipse。开发和调试本身很好但是如何让它们一起工作?
Play has its own web server (activator) that knows how to load the entry points for each endpoint and the dart environment know how to serve up dart resources (pub serve) for dartium and (haven't tried this yet) serve js resources for other browsers. It there a way for activator to ask the dart/pub system for resources as needed?
Play拥有自己的网络服务器(激活器),知道如何为每个端点加载入口点,并且dart环境知道如何为dartium提供dart资源(pub serve)和(还没有尝试过)为js资源提供服务其它浏览器。有没有办法让激活者根据需要向dart / pub系统询问资源?
I tried adding a symlink from the server static resource directly to to the dart/html resources but it seems these files need to be processed by pub server before they can be used by the browser.
我尝试将服务器静态资源中的符号链接直接添加到dart / html资源,但似乎这些文件需要由pub服务器处理才能被浏览器使用。
2 个解决方案
#1
I guess the best way is to use a proxy with rules to forward requests for Dart resources to pub serve
and play resources to activator
. This would be simple to build in Dart for example using shelf, shelf_route and shelf_proxy or nginx with a few forwarding rules.
我想最好的方法是使用带有规则的代理将Dart资源请求转发到pub serve并将资源播放到activator。这在Dart中构建起来很简单,例如使用shelf,shelf_route和shelf_proxy或者带有一些转发规则的nginx。
#2
Günter's suggestion was pretty good. I installed nginx and used the following config
Günter的建议非常好。我安装了nginx并使用了以下配置
server {
listen 8080;
server_name localhost;
location / {
# Dart pub serv
proxy_pass http://localhost:9100;
}
location /api/ {
# Play
proxy_pass http://localhost:9000/api/;
}
}
I then start the dart server as
然后我启动dart服务器
pub serve --port 9100
The typesafe/play server listens on 9000 by default.
typeafe / play服务器默认侦听9000。
I found I had to use a dart port number well away from the activator port because it seems to listen on nearby ports as well.
我发现我必须使用远离激活器端口的飞镖端口号,因为它似乎也在附近的端口上侦听。
Evan
#1
I guess the best way is to use a proxy with rules to forward requests for Dart resources to pub serve
and play resources to activator
. This would be simple to build in Dart for example using shelf, shelf_route and shelf_proxy or nginx with a few forwarding rules.
我想最好的方法是使用带有规则的代理将Dart资源请求转发到pub serve并将资源播放到activator。这在Dart中构建起来很简单,例如使用shelf,shelf_route和shelf_proxy或者带有一些转发规则的nginx。
#2
Günter's suggestion was pretty good. I installed nginx and used the following config
Günter的建议非常好。我安装了nginx并使用了以下配置
server {
listen 8080;
server_name localhost;
location / {
# Dart pub serv
proxy_pass http://localhost:9100;
}
location /api/ {
# Play
proxy_pass http://localhost:9000/api/;
}
}
I then start the dart server as
然后我启动dart服务器
pub serve --port 9100
The typesafe/play server listens on 9000 by default.
typeafe / play服务器默认侦听9000。
I found I had to use a dart port number well away from the activator port because it seems to listen on nearby ports as well.
我发现我必须使用远离激活器端口的飞镖端口号,因为它似乎也在附近的端口上侦听。
Evan