Comments (8)
Went from a 400 error to a 404 error. Using both cREST and node. No other details, just a plain 404 error.
var ruley = {
ALL: [
{'/api/v4/(.*)$':'api.cfm?v=4&fn=$1'}
]
}
var jsonrule = JSON.stringify(ruley);
console.log(jsonrule);
// REWRITE RULES: POST /host/<domain.com>/<port>/rule
it('POST a URL rewrite',function(done){
client.POST(root+'/host/'+props.hostname+'/'+props.port+'/rule', {json:jsonrule}, function(err,res,body){
//parseInt(res.statusCode).should.equal(201);
console.log(res.statusCode); //this reads 404
})
// done();
});
note the commented lines. this is purposely done so it times out and prints the statusCode.
if i run the following, the test passes (even though it actually returns a 404), AND the statusCode is never printed to the console.
it('POST a URL rewrite',function(done){
client.POST(root+'/host/'+props.hostname+'/'+props.port+'/rule', {json:ruley}, function(err,res,body){
parseInt(res.statusCode).should.equal(201);
console.log(res.statusCode);
})
done();
});
from ngn.
In your last code snippet, the done()
is not a part of the callback. It should be:
it('POST a URL rewrite',function(done){
client.POST(root+'/host/'+props.hostname+'/'+props.port+'/rule', {json:ruley}, function(err,res,body){
parseInt(res.statusCode).should.equal(201);
console.log(res.statusCode);
done(); // <--- Moved to here
})
// From Here
});
A 404
is only returned when the endpoint doesn't exist. So, I'm not sure why you're seeing that... might help to post a gist of your code.
from ngn.
Sorry... a 404
can show up when the endpoint doesn't exist, but more importantly, it will show up when <domain.com>
cannot be found.
I'll see what I can do about separating these return codes. I think a 400
or bad request
makes more sense if the endpoint doesn't exist. The 404
makes sense when the domain is missing or does not exist.
from ngn.
I simply cannot get it to POST a rewrite rule. For giggles, I set up a web server running the simple eventionary on port 2500. My proxy is running on port 7770, and when I do localhost:7770, I am able to see the eventionary in the browser (so I know the domain.com is being found). I can GET and DELETE rules using a REST client, but when I try to POST a valid JSON rule, it still gives me a 404.
from ngn.
I believe the problem is the documentation. The great laptop genocide of October 3rd (where 3 laptops died) appears to have caused some loss in a few updates... not in the code, but the docs. The endpoint you're currently using, which is POST <base>/host/<hostname.com>/rule
should actually be POST <base>/host/<hostname.com>/rule/<method>
where <method>
is the HTTP verb (GET, POST, PUT, DELETE) or ALL
. The body is a single rule, like:
{"regex_pattern":"substitute"}
I'm reopening this until the documentation reflects these changes.
from ngn.
Ah ok, that makes sense. Unfortunately, I believe the problem persists.
I tried POSTing
{"/v9":"api9.html"}
to
/host//port/rule/GETI get a 400 "Missing attribute: pattern and/or substitute" still.
from ngn.
furthermore, when I view (GET) the list of hosts, the "pattern" section of each rule is simply { }, only the substitute is shown. so, even though the cache.json file says:
"ALL": [
{
"/api/v3/(.*)$": "api.cfm?v=3&fn=$1"
}
]
the JSON output of the GET method looks like
"ALL": [
{
"pattern": {},
"substitute": "api.cfm?v=3&fn=$1",
"path": null,
"last": false,
"rewritten": false,
"acceptMethod": [
"GET",
"POST",
"PUT",
"DELETE",
"HEAD",
"TRACE"
]
}
]
from ngn.
There was an issue parsing the body of the POST, which has been fixed in the master branch.
Also, I had a typo in my last comment. The endpoint for creating a rule is
CORRECT: POST <base>/host/<hostname.com>/<port>/rule/<method>
Incorrect: POST <base>/host/<hostname.com>/rule/<method>
(port is missing).
from ngn.
Related Issues (20)
- NGN.DATA.Store#forEach
- Function Library (core?)
- NGN.DATA Date Type
- Iodine
- Loading Nested Models
- JSON/XML Schema Support
- Data Virtual Fields
- NGN.needs Fails in IE 11 due to MissingDependencyError HOT 1
- NGN.DATA.View & NGN.DATA.MaterializedView
- Data Model & Store Updates
- NGN.NET Redirect Cache
- Inaccessible documentation HOT 1
- EE.forward pooling behavior
- NGN.EventEmitter Separator HOT 1
- Need a standardized event naming syntax HOT 4
- ReferenceError: require is not defined HOT 1
- No default jsDelivr CDN file set
- Auto-recognize custom errors on NGN Ledger
- Class Parents, Children, and Siblings
- Export Map
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngn.