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

outdated

Amix is a package for creating Servers.

example/amix_example.dart

import 'dart:io';
import 'package:amix/amix.dart';

void main() async {
  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);
            }
          },
        );
      },
    );
    routeController.createRoute(
      "/hi2",
      onCall: (AmixRequest request) {
        return AmixResponse(
          response: (response) async {
            response.write("hello world2!!");
            await response.close();
          },
        );
      },
    );
  }

  @override
  AmixResponse onPageNotFound() {
    return AmixResponse(
      response: (HttpResponse response) async {
        response.statusCode = 404;
        response.write("Page Not Found 404");
        await response.flush();
        await response.close();
      },
    );
  }
}
0
likes
0
points
75
downloads

Publisher

unverified uploader

Weekly Downloads

Amix is a package for creating Servers.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on amix