1. Magnus Hoff
  2. resource-tree
Issue #1 new

Passthrough

Anonymous created an issue

Looking at implementing passthrough when a request does not match any existing routes. Do you think passthrough should be always-on? Or that it should be specified as an option when creating the handler? I ask, because if it's an option, then I will need to introduce an options parameter to a number of functions, which could be a breaking change in some cases.

Comments (3)

  1. Magnus Hoff repo owner

    If I have correctly guessed what "passthrough" is supposed to be, it looks a lot like a user supplied 404-handler, which the library will need at some point anyway. I'm thinking it could end up looking something like this:

    handleRequest(req, res, {
        root: root,
        handle404: function (req, res) {
            // Call other http handler, if that's your cup of tea
            // Otherwise, present awesome 404 page
        },
        handle500: function () { /* blah */ }
        // Although, we probably want one handleError thing to rule them all
        // to make the "present error message" usecase better
    });
    

    It should definitely be optional. People should be able to get a simple server up and running without giving special consideration to 404.

    It should definitely be beautiful :) Especially the simplest usecases.

    It should probably look like express when using it with express. At least if people expect that :)

    Breaking changes are OK. We are currently at version 0.0.0-4 of the library :)

    (Incidentally discovered this feature while writing this comment: https://bitbucket.org/site/master/issue/5919/pressing-esc-in-a-bug-comment-editor )

  2. Magnus Hoff repo owner

    To put even more words down, I suppose the core would have a handleError-thing, but the library might expose a function (res, req, next) kind of API to work well with other stuff. And stuff.

  3. Log in to comment