webart_resource 0.0.1 copy "webart_resource: ^0.0.1" to clipboard
webart_resource: ^0.0.1 copied to clipboard

Dart 1 only

A simple way to reorganize resources in your web application

example/example.dart

import 'dart:async';
import 'package:webart/webart.dart';
import 'package:webart_resource/webart_resource.dart';


class ExampleResource implements RemoveableResource<Map,Map>{
    String address = "example";
    Map<String,Map<String,dynamic>> memories;

    ExampleResource(){
        memories = {};
    }

  @override
  Future<Map> get(Map entry) async {
      String key = entry['key'];
    var res = memories[key];
    if (res == null) throw new ResourceNotFound();
    return res;
  }

  @override
  Future<dynamic> remove(Map entry) async {
    String key = entry['key'];
    memories.remove(key);
    return;
  }

  @override
  Future<dynamic> save(Map entry, Map res) async {
    String key = entry['key'];
    memories[key] = res;
    return;
  }
}

main() async{
    var app = new Application(new Config({
        'routes': {},
        'resources': [
            new ExampleResource()
        ]
    }));
    app.use(new ResourcePlugin());
    await app.start('127.0.0.1', 8089);
}
0
likes
35
points
3
downloads

Publisher

unverified uploader

Weekly Downloads

A simple way to reorganize resources in your web application

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

webart

More

Packages that depend on webart_resource