小编roh*_*pal的帖子

NodeJS中不同路径的并行请求:长时间运行路径1阻塞其他路径

我正在尝试简单的NodeJS应用程序,以便我能够理解异步性质.

但我的问题是,一旦我/home从浏览器点击" "它等待响应,同时当" /"被击中时,它首先等待/home""的响应,然后响应" /"请求.

我担心的是,如果其中一个请求需要大量处理,那么我们不能再请求另一个请求了吗?它是否正确?

    app.get("/", function(request, response) {
        console.log("/ invoked");
        response.writeHead(200, {'Content-Type' : 'text/plain'});
        response.write('Logged in! Welcome!');
        response.end();
    });

    app.get("/home", function(request, response) {
        console.log("/home invoked");
        var obj = {
            "fname" : "Dead",
            "lname" : "Pool"
        }
        for (var i = 0; i < 999999999; i++) {
            for (var i = 0; i < 2; i++) {
                // BS
            };  
        };
        response.writeHead(200, {'Content-Type' : 'application/json'});
        response.write(JSON.stringify(obj));
        response.end();
    });
Run Code Online (Sandbox Code Playgroud)

node.js

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

Grails 3 - Spring Rest Docs使用Rest确保在使用JSON视图时提供SnippetException

我正在尝试将Spring REST文档与Grails 3.1.4应用程序放心.我正在使用JSON视图.

完整代码位于https://github.com/rohitpal99/rest-docs

在我使用的NoteController中

List<Note> noteList = Note.findAll()
Map response = [totalCount: noteList.size(), type: "note"]
render response as grails.converters.JSON
Run Code Online (Sandbox Code Playgroud)

文档生成效果很好.

但我想使用像JSON这样的视图

respond Note.findAll()
Run Code Online (Sandbox Code Playgroud)

我在/ views目录中有_notes.gson和index.gson文件.我得到一个SnippetException.通常/注释GET请求响应是正确的.

rest.docs.ApiDocumentationSpec > test and document get request for /index FAILED
    org.springframework.restdocs.snippet.SnippetException at ApiDocumentationSpec.groovy:54
Run Code Online (Sandbox Code Playgroud)

没有消息.无法跟踪它发生的原因.请建议.

完整的堆栈跟踪

    org.springframework.restdocs.snippet.SnippetException: The following parts of the payload were not documented:
{
  "instanceList" : [ {
    "title" : "Hello, World!",
    "body" : "Integration Test from Hello"
  }, {
    "title" : "Hello, Grails",
    "body" : "Integration Test from Grails"
  } …
Run Code Online (Sandbox Code Playgroud)

rest grails spring spring-restdocs grails-3.1

3
推荐指数
2
解决办法
2968
查看次数

标签 统计

grails ×1

grails-3.1 ×1

node.js ×1

rest ×1

spring ×1

spring-restdocs ×1