A RestFul Api library for Dart developers.

Usage

restful api for small things...

your app.dart file example: app.dart


import 'package:restful/restful.dart';

void main() async {
  /// Step#1 register routes
  Api.auto('/', 'Hello world'); 
  Api.get('/index.html', File('example/html/index.html'));
  Api.get('/some.route', () {
    return 'some function';
  });
  Api.get('/some.json', () {
    return Api.json({
      'msg': 'some function',
      'list': [0, 1, 2]
    });
  });

  /// Step#2  start listen api
  await Api.listen(host: '127.0.0.1', port: 4040);

  /// Step#3 open http://127.0.0.1:4040/ visit on browser
}

Listening on http://127.0.0.1:4040/

Docker configuration:

Dockerfile

#!/bin/bash

version="dart-restful"

docker build -t "$version" .

docker run -d -p 4040:4040 --name="$version-test" "$version"

docker ps

Libraries

restful
restful_iml