index.php 442 B

123456789101112131415161718192021222324
  1. <?php
  2. require __DIR__.'/vendor/autoload.php';
  3. app()->get("/plaintext", function () {
  4. response()->plain('Hello, World!');
  5. });
  6. app()->get('/json', function () {
  7. response()->json(['message' => 'Hello, World!']);
  8. });
  9. app()->run(); // commented with workerman
  10. // Workerman
  11. function run(): string
  12. {
  13. ob_start();
  14. app()->run();
  15. header(HeaderDate::$date); // To pass the bench, nginx auto add it
  16. return ob_get_clean();
  17. }