Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST to route returns 404 #10

Closed
AllSpeeds opened this issue Apr 10, 2014 · 7 comments
Closed

POST to route returns 404 #10

AllSpeeds opened this issue Apr 10, 2014 · 7 comments

Comments

@AllSpeeds
Copy link

GIVEN route table:

"router": {
        "options": {
          "routes": {
            "someGetRoute": {
              "method": "GET",
              "name": "someGetRoute",
              "path": "/someGetRoute",
              "description": "Example GET route",
              "handler": "someGetRoute",
              "params": {},
              "enabled": true
            },
            "somePostRoute": {
              "method": "POST",
              "name": "somePostRoute",
              "path": "/somePostRoute",
              "description": "Example POST route",
              "handler": "somePostRoute",
              "params": {},
              "enabled": true
            }
}
}
}

WHEN looping over routes looking for a match
AND when matched
AND when method matches
THEN move on

Currently, this code (https://github.com/tommymessbauer/pipeline-router/blob/master/index.js#L123):

    // quick fail check
    if (matched || httpContext.request.method !== options.method) {
      next();
    }

will not find a match OR the method will not match and fire next() and end with match undefined which returns a 404 as the POST response:

this.plRouter.on('end', function(err, results) {
    var matched = results[0].matched,
        res = results[0].httpContext.response;

    that.emit('end', err, results);

    if ((!matched || err) && res) {
      res.statusCode = 404;
      res.write("No matching route or failed route");
      res.end(err ? err.stack : '');
    }
  });
@AllSpeeds
Copy link
Author

Forked, writing a test with a route table and going to submit a PR.

@panthershark
Copy link
Owner

Route tables are part of https://github.com/mixdown/router, not pipeline-router.

@panthershark
Copy link
Owner

next() does not end the pipeline. It tells the pipeline to try the next step.

@AllSpeeds
Copy link
Author

@tommymessbauer You're right, next() does not necessarily end the pipeline. You're also right about the route table, however are you saying the fix for this is in mixdown-router? The code path still breaks.

@panthershark
Copy link
Owner

I am just saying that you cannot initialize a pipeline router with a route table. Mixdown-router uses a route table.

@AllSpeeds
Copy link
Author

yeah and you said it 6 times....I get it.

@panthershark
Copy link
Owner

I promise that was a github bug. I pressed "Comment" and it did nothing. So it took 6 tries before I realized that the page was not updating correctly.

AllSpeeds pushed a commit to AllSpeeds/pipeline-router that referenced this issue Apr 10, 2014
@AllSpeeds AllSpeeds closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants