我在Docker Compose中遇到错误.撰写文件是
version: '2'
services:
api:
build:
context: .
dockerfile: webapi/dockerfile
ports:
- 210
web:
build:
context: .
dockerfile: app/dockerfile
ports:
- 80
lbapi:
image: dockercloud/haproxy
links:
– api
ports:
– 8080:210
lbweb:
image: dockercloud/haproxy
links:
– web
ports:
– 80:80
Run Code Online (Sandbox Code Playgroud)
运行时的错误docker-compose up是:
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
services.lbapi.ports contains an invalid type, it should be an array
services.lbweb.ports contains an invalid type, it should be an array
services.lbapi.links contains an invalid type, it should …Run Code Online (Sandbox Code Playgroud) 对于传入的 HTTP 请求,我必须使用202 Accepted状态代码进行响应,同时继续在后台处理有效负载。例如,这就是我目前正在做的事情:
package main
import (
"fmt"
"log"
"net/http"
"time"
"github.com/nbari/violetear"
)
func sleep() {
time.Sleep(3 * time.Second)
fmt.Println("done...")
}
func index(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusAccepted)
go sleep()
}
func main() {
router := violetear.New()
router.HandleFunc("*", index)
http.Handle("/", router)
log.Fatal(http.ListenAndServe(":8080", router))
}
Run Code Online (Sandbox Code Playgroud)
基本上,在处理程序上我只使用,然后在 goroutine 中WriteHeader调用该函数:sleep
func index(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusAccepted)
go sleep()
}
Run Code Online (Sandbox Code Playgroud)
如果我想回复“200 OK”,我注意到我可以简单地返回,例如:
func index(w http.ResponseWriter, r *http.Request) {
go sleep()
return
}
Run Code Online (Sandbox Code Playgroud)
因此想知道我是否应该总是返回我想关闭:
func index(w http.ResponseWriter, r …Run Code Online (Sandbox Code Playgroud) 以下代码仅针对name属性引发错误.可以通过name在属性中将属性指定为可写来修复它,Object.create但我试图理解为什么会发生这种情况(并且可能有更优雅的方法来修复它).
var BaseClass = function (data) {
Object.assign(this, data);
}
var ExtendedClass = function () {
BaseClass.apply(this, arguments);
}
ExtendedClass.prototype = Object.create(BaseClass);
console.log(new ExtendedClass({ type: 'foo' }));
new ExtendedClass({ name: 'foo' });Run Code Online (Sandbox Code Playgroud)
我想知道browser-window的当前 URL 。有没有办法访问 BrowserWindow 的 window.location.href 属性或任何其他方式来获取它?