• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

metalabdesign / http-middleware-metalab / 193
96%
master: 97%

Build:
Build:
LAST BUILD BRANCH: midori
DEFAULT BRANCH: master
Ran 01 Feb 2016 07:46PM UTC
Jobs 3
Files 26
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
193

push

travis-ci

izaakschroeder
Add `thunk` middleware.

Sometimes you want to change the processing mechanism of your application at runtime instead of construction time. For example:

```javascript
const app = compose(
  match(path('/foo'), send())
);
```

This app structure is static; what if we wanted routes from a database? Such a thing is now possible in relatively elegant fashion:

```javascript
const app = compose(
  thunk((app) => {
    let result = app;
    db.on('update', (routes) => {
      result = routes.reduce((result, route) => {
        return middlewareForRoute(route)(result);
      }, app);
    });
    return () => result;
  })
);
```

The `thunk` middleware basically defers access to the appropriate method (e.g. `request`, `error`, etc.) to the last possible moment at which point it calls the thunk to get the method at that instant.

347 of 362 relevant lines covered (95.86%)

10.46 hits per line

Jobs
ID Job ID Ran Files Coverage
1 193.1 01 Feb 2016 07:47PM UTC 0
95.66
Travis Job 193.1
2 193.2 01 Feb 2016 07:48PM UTC 0
95.86
Travis Job 193.2
3 193.3 01 Feb 2016 07:46PM UTC 0
95.86
Travis Job 193.3
Source Files on build 193
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #193
  • 98afe75a on github
  • Next Build on thunk (#195)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc