Support Web APIs.
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1.6k
- Forks
- 239
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 10
Description
@xeioex @drsm
Web APIs is an alternative usage.
https://developer.mozilla.org/en-US/docs/Web/API/Response/Response
It will behave in njs like below.
function hello(request) {
return new Response('hello');
}
function subrequest(request) {
var sr = new Request('/sub');
sr.fetch()
.then(response) {
return response;
};
}
In the beginning, njs has individual response object. foo(req, res). After that, res is merged into req, so we have to rename some methods like headersIn, headersOut.
If we introduce these things, Request, Response, Headers, Body, I believe it can be easier to use, and we just implement the standard methods with them.
The second change is that the subrequest is also easier to use. Indeed, users need not know what subrequest is, they just want to send a request. (But the implementation will be upon on nginx subrequest).
Still, further, it can be welcome after async, await are introduced.
Highly welcome to your suggestions. I'd like to try it without changing current usage by put them in precontent phase.
I'm still not familiar with async, await, Promise, it's good to have a better example of how to write with subrequest below. @drsm
BTW, do you know whether the above objects are standard belong to js?
I'm wondering which software has already implemented them, where are they used?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed MDN Response API and the existing njs request/response usage described in the issue, including the precontent phase and nginx subrequest behavior. Done would require a settled design and implementation for Request, Response, Headers, and Body without changing current usage, plus clearer subrequest examples and validation of the async model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100