小编che*_*eze的帖子

如何在没有裸域的情况下仅将子域映射到 App Engine?

我的用例是这样的:我有一个域指向 IP 1.2.3.4 的服务器,我希望域中的子域指向我的 App Engine 应用程序,即

example.com --> 1.2.3.4

app.example.com --> App Engine 应用程序

裸域以及 www 子域必须指向独立服务器。

从我目前发现的情况来看,这似乎是不可能的。

任何人都可以确认这种配置是否确实不可能?

google-app-engine

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

如何使用 Go 指定 App Engine 模板路径进行单元测试?

我在 App Engine 上使用 Go 的内置模板包。

我有一个处理程序,可以将模板渲染到输出。

templates := []string{"templates/head.html", "templates/footer.html"}

func pageIndex(w http.ResponseWriter, r *http.Request) {
  tpls := append([]string{"templates/index.html"}, templates...)
  tpl := template.Must(template.ParseFiles(tpls...))
  err := tpl.ExecuteTemplate(w, "index", map[string]string{
    "Title": "Index Page",
  })

  if err != nil {
    http.Error(w, err.Error(), http.StatusInternalServerError)
  }
}
Run Code Online (Sandbox Code Playgroud)

当我运行本地开发服务器时,效果很好。

当我运行单元测试来测试页面时,它会出现恐慌并给出消息:

恐慌:打开 templates/index.html:没有这样的文件或目录 [已恢复]

单元测试如下:

func TestPageIndex(t *testing.T) {
  inst, _ := aetest.NewInstance(nil)
  //ignoring the errors for brevity
  defer inst.Close()

  req, _ := inst.NewRequest("GET", "/", nil)
  resp := httptest.NewRecorder()
  pageIndex(resp, req)
}
Run Code Online (Sandbox Code Playgroud)

基本上,问题是对于单元测试,服务器无法找到模板的路径。

运行测试时如何指定模板文件的路径?

google-app-engine templates unit-testing go

5
推荐指数
1
解决办法
1487
查看次数

rollup-plugin-vue v4.6.2的vue-runtime-helpers有问题

rollup-plugin-vue的最新(截至撰写时)版本为4.6.2。

它依赖于vue-runtime-helpers版本1.0.0

这个版本有错误。尝试使用汇总创建捆绑包时,会产生错误

错误:node_modules / vue-runtime-helpers / dist / normalize-component.js未导出“默认”

在此之前,使用vue-runtime-helpers 0.2.0版的rollup-plugin-vue版本4.6.1可以正常工作。

vue.js

2
推荐指数
1
解决办法
1732
查看次数

无法在Jackson中使用JsonParser进行反序列化

我正在尝试使用org.codehaus.jackson.map.deser.std.StdDeserializer自定义反序列化.

我的主要目标是能够连接到Jetty的JSON处理结构并使用Jackson而不是默认的JettyJSON.

所以现在,我正在测试是否有效.

我有一个测试,试图读取一个简单的JSON字符串并将其转换为Presence对象.

public void testBasicJson() throws JsonParseException,
        JsonMappingException,
        IOException {
    ObjectMapper mapper = new ObjectMapper();
    JsonObjectDeserializer jod = new JsonObjectDeserializer();
    SimpleModule module = new SimpleModule("JsonObjectDeserializer",
        new Version(1, 0, 0, null));
    module.addDeserializer(JsonObject.class, jod);
    mapper.registerModule(module);

    //formatted for easy reading
    String jsonSimple = "{
        \"userEmail\":\"user1@lab.com\",
        \"type\":\"presence\",
        \"domain\":\"lab.com\"
    }";
    JsonObject pres = mapper.readValue(jsonSimple, JsonObject.class);
    System.out.println(pres.toString());
}
Run Code Online (Sandbox Code Playgroud)

Presence类是:

public class Presence extends JsonObject {
    private static final long serialVersionUID    = 1L;
    protected String userEmail;
    protected String domain;
    protected String type;

    public …
Run Code Online (Sandbox Code Playgroud)

java json jetty jackson deserialization

0
推荐指数
1
解决办法
4155
查看次数