mojito 0.0.4 mojito: ^0.0.4 copied to clipboard
A micro framework for modern web apps built from the ground up on the shelf framework
A micro framework for modern web apps built from the ground up on the shelf framework #
Introduction #
A micro framework for modern web apps built from the ground up on the Shelf Framework.
Like its namesake, Mojito is mostly sugar and a blend of other ingredients. Mojito is deliberately a very thin layer over several shelf packages and focuses on the overall experience of building an application.
The focus of Mojito is on modern rich web apps that have a clean separation of ui from services. As such it doesn't bundle any server side templating packages although these can be easily added.
The core architecture of Mojito is shelf itself. All components are existing pub packages that are built from the ground up as shelf components. This makes it super easy to take advantage of any new shelf based packages that come along in the future
Usage #
Import and initialise
import 'package:mojito/mojito.dart';
final app = mojito.init();
Set up some global authentication. These will be applied to all routes.
app.auth.global
.basic(_lookup)
..allowHttp=true
..allowAnonymousAccess=true;
Set up a proxy to pub serve to serve your ui in dev.
app.proxyPubServe();
Set up a route and get the authenticated users name from the context. Note: Mojito makes the logged in user available in the current zone.
app.router..get('/hi', () {
var auth = app.context.auth;
var username = auth.map((authContext) =>
authContext.principal.name)
.getOrElse(() => 'guest');
return 'hello $username';
});
Start serving the app
app.start();
Under the hood #
Mojito bundles lots of existing shelf libraries and integrates them for easier use. These include:
- Shelf Route
- Shelf Bind
- Shelf Rest
- Shelf Auth
- Shelf OAuth
- Shelf Proxy
- Shelf Static
- Shelf Exception Response
More doco to come...