Main.vala 1.0 KB

1234567891011121314151617181920212223242526272829
  1. using Astralis;
  2. using Inversion;
  3. using Statum;
  4. using Example;
  5. void main(string[] args) {
  6. int port = args.length > 1 ? int.parse(args[1]) : 8080;
  7. try {
  8. var application = new WebApplication(port);
  9. application.use_compression();
  10. application.add_module<StatumModule>();
  11. var statum = application.configure_with<StatumConfigurator>();
  12. // HomePage is generated from home.html; HomeEntrypoint hydrates it.
  13. // The Statum client scripts (statum.js / statum-worker.js) are embedded in
  14. // the library and served by default, so only the page-specific CSS needs
  15. // registering here.
  16. statum.add_entrypoint_page<HomePage, HomeEntrypoint>(new EndpointRoute("/"));
  17. statum.add_action<LoginAction>(new EndpointRoute("/login", Method.POST));
  18. statum.add_action<LogoutAction>(new EndpointRoute("/logout", Method.POST));
  19. statum.add_resource<StylesResource>();
  20. application.run();
  21. } catch (Error e) {
  22. printerr("Error: %s\n", e.message);
  23. Process.exit(1);
  24. }
  25. }