REST-style API server inspired by Dart's rpc package.
Corsac RPC uses standard HttpServer
from dart:io
as well as
some of the corsac-dart components including
corsac-dart/kernel,
corsac-dart/router.
This library is a work-in-progress so breaking changes may occur without notice.
Here is simplest "Hello World" implementation:
// file: main.dart
library hello_world;
import 'package:corsac_rpc/corsac_rpc.dart';
import 'package:logging/logging.dart';
@ApiResource(path: '/hello-world/{name}')
class HelloWorldResource {
@ApiMethod.GET
HttpApiResponse getHelloWorld(String name) {
return new HttpApiResponse.json({'myNameIs': name});
}
}
main() async {
final kernel = await Kernel.build('prod', {}, []);
final app = new ApiServer(kernel, [HelloWorldResource]);
app.start();
}
- Introduction
- API Resources
- Middleware pipeline
- Additional middlewares:
- PrefixMiddleware
- VersionMiddleware