我正在尝试简单的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) 我正在尝试将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)