Skip to content

Instantly share code, notes, and snippets.

@mraleph
Created November 13, 2017 20:11
Show Gist options
  • Save mraleph/63be907f18e1ca55991d69fed5608833 to your computer and use it in GitHub Desktop.
Save mraleph/63be907f18e1ca55991d69fed5608833 to your computer and use it in GitHub Desktop.
class Nothing { const Nothing(); }
class Pipeable {
var value = const Nothing();
operator |(f) {
if (f == const Nothing()) {
return value;
} else if (value == const Nothing()) {
value = f();
} else {
value = f(value);
}
return this;
}
}
pipeline() => new Pipeable();
const done = const Nothing();
final response = pipeline()
| loadConfig
| buildDic
| getApp
| getRouter
| (_) => getDispatcher(_, request)
| (_) => dispatchBusinessLogic(_, request, new Response())
| renderResponse
| buildResponse
| emit
| done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment