webart_resource 0.0.1

  • README.md
  • Example
  • Installing
  • Versions
  • 0

webart_resource

A simple way to reorganize resources in your web application.

STATUS: Alpha Version!

It just a easy work for now, please don't use it in production if you do not know what you are doing.

STATUS: Offer Dart 1.x support only

webart still only offer dart 1.x support, so this plugin could not run on dart 2 strong mode.
But it looks like useless that upgrade to dart 2 if you are using dart in backend.

How to use

  1. Include it in your pubspec.yaml
dependencies:
  webart: ^0.2.6
  webart_resource: ^0.0.1
  1. Import it in your code
import "package:webart_resource/webart_resource.dart";
  1. Define some resources
class MyResource implements Resource<Map,Map>{ ... }
  1. Put them in your config
var app = new Application(new Config({
    'routes':{ ... },
    'resources': [
        new MyResource(),
        new OtherResource()
    ]
}));
  1. Use ResourcePlugin
app.use(new ResourcePlugin());

There is a example in 'example/example.dart' that has more infomation.

Documents

Aren't finished yet.

License

Copyright 2018 thisLight

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  webart_resource: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:webart_resource/webart_resource.dart';
  
Version Uploaded Documentation Archive
0.0.1 Aug 19, 2018 Go to the documentation of webart_resource 0.0.1 Download webart_resource 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0