dchisel
一个用于创建REST API的简单Dart Web框架。DChisel支持自定义中间件以及MySQL和PostgreSQL ORM。
DChisel 是一个简单的 Dart 框架,用于创建 REST API
以下为英文项目原文快照,最新内容请访问 GitHub。
DChisel is simple Dart Framework for creating REST API
To add the dchisel to your Dart application read the install instructions.
Default host is "localhost" and port 8000
import 'package:dchisel/dchisel.dart';
Future<void> main(List<String> arguments) async {
DRoute route() {
var droute = DRoute();
droute.get('/', (Request req) async => resOk("Hello, DChisel"));
return droute;
}
DChisel().serve(getroutes: route());
}
If you want to change the host to 0.0.0.0 and port to 5555 you can use :
DChisel().serve(getroutes: route(), serverHost: '0.0.0.0', serverPort: 5555);
droute.get('/hello', (Request request) {
return 'Hello, World';
});
GET with param you can use :
droute.get('/getparam/<name>', (Request request, String name) {
return 'Hello, $name';
});
droute.post('/hello', (Request request) async {
return 'Hello, World';
});
If you want to get Body value from your POST request, use :
var body = await request.body.asJson;
If you want to get Header value from your POST request, use :
var headers = await request.headers;
droute.put('/hello/<name>', (Request request, String name) async {
return 'Hello, $name';
});
PUT also can get Header and Body request
var headers = await request.headers;
var body = await request.body.asJson;
droute.delete('/hello/<name>', (Request request, String name) async {
return 'Hello, $name';
});
For now, DChisel only support PostgreSQL and MySQL
DChiselDB().configDB('dialect', // DIALECT DATABASE, IF YOU USE POSTGRESQL CHANGE 'dialect' to 'postgre', IF YOU USE MYSQL CHANGE 'dialect' to 'mysql'
host: 'your_host',
db: 'your_db_name',
port: your_port, //integer
username: 'your_db_username',
password: 'your_db_password');
DChiselDB().getAll('your_table_name');
DChiselDB().getOption('your_table_name',
column: 'your_column1,your_column2',
where: ['your_column_name', 'your_filter_value']);
If you want filter contains, just add % into your filter value, example :
'%your_filter_value%'
DChiselDB().create('users', data: {
'your_column_name': 'your_value'
});
DChiselDB().update('users', data: {
'your_column_name': 'your_value'
}, where: ['your_filter_column_name', 'your_filter_value']);
DChiselDB().deleteAll('your_table_name');
DChiselDB().deleteOption('your_table_name', where: ['your_filter_column_name', 'your_filter_value']);
Please file any issues, bugs or feature requests as an issue on our GitHub page. Commercial support is available, you can contact us at <alphacsoft@gmail.com>.
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.
This dchisel framework for Dart is developed by Alphacsoft.
依赖清单 13 项
^1.8.0^1.4.0^1.1.3^2.4.2^1.5.0^0.0.27^0.12.2+1^1.3.0^1.1.1^2.4.0^3.0.1^0.1.2^3.0.0先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗