Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

arowana

a lightweight http server framework for dart.it is based on the shelf library for handling http requests and implements a high-performance routing with reference to golang’s gin framework.

usage

a simple usage example:

import 'dart:isolate';
import 'package:arowana/arowana.dart';

class myachannel extends defaultchannel{

  @override
  future prepare() {
    print('current isolate [${isolate.current.debugname}]');
    return super.prepare();
  }

  @override
  void entrypoint() {
    get('/hello', (r){
      return response.ok('hello,arowana!');
    });
  }
}


void main() {
  var app = application(myachannel());
  app.start(numberofinstances: 2,consolelogging: true);
}

another example, containing grouped routes:

class myachannel extends appchannel {
  router app = router();

  middleware verification() => (innerhandler) {
        return (request) async {
          if (request.query['name'] == 'abc' &&
              request.query['pass'] == '123') {
            return await innerhandler(request);
          } else {
            return responsex.unauthorized('authentication failed !!!');
          }
        };
      };

  @override
  void entrypoint() {
    var r1 = app.group('/v1');

    // var middleware = pipeline().addmiddleware(verification()).middleware;
    r1.use(verification());
    r1.get('/hello', (request request) {
      return response.ok('hello-world');
    });

    r1.get('/greet/:name', (request request, string name) {
      return response.ok('hi,$name');
    });

    var r2 = app.group('/v2');
    r2.get('/hello', (request request) {
      return response.ok('hello,arowana');
    });
    r2.get('/user/:name', (request request, string user) {
      return response.ok('hello, $user');
    });
  }

  @override
  futureor<response> call(request request) {
    print('current isolate [${isolate.current.debugname}]');
    return app.call(request);
  }
}

void main() {
  var app = application(myachannel());
  app.options = applicationoptions()..address = '127.0.0.1';
  app.start(numberofinstances: 2,consolelogging: true);
}

features and bugs

please file feature requests and bugs at the issue tracker.


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.