amix 0.0.12
amix: ^0.0.12 copied to clipboard
a package for creating Servers.
a Package for creating Servers.
Features #
With this package, you can easily create your own servers. This package automatically manages your isolates and you don't need to get involved with isolates.
Getting started #
Add the following to your pubspec.yaml file.
dependencies:
amix: ^0.0.12
Import the package.
import 'package:amix/amix.dart'
Usage #
import 'dart:io';
import 'package:amix/amix.dart';
void main() async {
serverAddress = "127.0.0.1";
serverPort=8080;
AmixSetUp exampleServer = AmixSetUp(serverRoute: AmixRouteExample());
await exampleServer.startMultiCoreServer(isolateCount: 10);
}
class AmixRouteExample extends AmixRoute {
@override
void setEntryPoints() {
routeController.createRoute(
"/hi",
onCall: (AmixRequest request) {
return AmixResponse(
response: (response) async {
try {
response.write("hello world!!");
await response.flush();
await response.close();
} catch (e) {
print(e);
}
},
);
},
);
}
@override
AmixResponse onPageNotFound() {
return AmixResponse(
response: (HttpResponse response) async {
response.statusCode = 404;
response.write("Page Not Found 404");
await response.flush();
await response.close();
},
);
}
}