Skip to content

Microframework for Dart inspired by Bottle and Echo

License

Notifications You must be signed in to change notification settings

TenderOwl/laska

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laska

Laska is a server-side microframework for Dart, which aims to be a fast, simple and lightweight.

  • Routing: Requests to function-call mapping with support for clean and dynamic URLs.
  • Middlewares: Middlwares allow developers to modify request before it's being processed.
  • Isolates: Laska uses Isolates to secure request processing.

Example: "Hello world" in a Laska

import 'package:laska/laska.dart';

void main() async {
  final laska = Laska();

  laska.GET('/hello/:name',
      (context) async => await context.Text("Hello ${context.param('name')}!"));

  await run(laska);
}

Run this script via dart run hello_world.dart, then point your browser to http://localhost:3789/hello/world. That’s it.

Current state

Active development, not for production use.

Full Example

import 'dart:io';

import 'package:laska/laska.dart';

void main() async {
  // Create new Laska object
  final laska = Laska();

  // Set global BasicAuth middleware 
  laska.use(BasicAuth('laska', 'ermine', realm: 'Access to private zone'));

  laska.get('/users/:userId', getUserById);
  laska.post('/users/', createUser);

  // Start server
  await run(laska);
}

void getUserById(Context context) async {
  await context.html('User: <b>${context.params['userId']}</b>');
}

void createUser(Context context) async {
  await context.json({'status': 'created'}, statusCode: HttpStatus.created);
}

Routing

Laska uses a powerful routing engine to find the right callback for each request. it's based on Trie data structure which let it be very performant.

License

MIT

About

Microframework for Dart inspired by Bottle and Echo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages