From 10f166b7d3a6225d9fb04453c8b92fc261f316dc Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Sat, 19 Oct 2024 11:24:12 +0100 Subject: [PATCH] docs: update readme --- README.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6303b9d..aa88f1b 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,39 @@

- Discord + + Discord + - Contributors - - Total downloads + + Contributors + + + + Total downloads + Examples

+## Features + +- 🚀 Lightweight and fast +- 🧩 Middleware support +- 🛣️ Flexible routing with parameters +- 🔒 Built-in security features (CSRF, JWT) +- 🍪 Cookie management +- 📅 Date helpers +- 🔍 Request ID for tracing +- 📁 Static file serving +- 🔐 Basic and Bearer authentication +- 📝 Logging support +- 🗃️ HTTP caching +- 🔄 CORS support +- 🧬 Environment-based configuration + ## Install ```bash @@ -33,12 +55,32 @@ Here's a basic example of how it works! ```php get("/", function ($context) { - return $context->json(["message" => "Hello, Dumbo!"]); +$app->use(function ($context, $next) { + $context->set('message', 'Hello from middleware!'); + return $next($context); +}); + +$app->get('/', function ($context) { + return $context->json([ + 'message' => $context->get('message'), + 'timestamp' => time() + ]); +}); + +$app->get('/users/:id', function ($context) { + $id = $context->req->param('id'); + return $context->json(['userId' => $id]); +}); + +$app->post('/users', function ($context) { + $body = $context->req->body(); + return $context->json($body, 201); }); $app->run(); @@ -46,7 +88,23 @@ $app->run(); See the [examples](/examples) directory for more quickstarts. -## Routing +## License + +Dumbo is open-sourced software licensed under the [MIT license](LICENSE). + +## Contributors + +![Contributors](https://contrib.nn.ci/api?repo=notrab/dumbo) + + + + good first issue + + + +## Documentation + +### Routing ```php put('/users/:id', function($context) { /* ... */ }); $app->delete('/users/:id', function($context) { /* ... */ }); ``` -### Params +#### Params ```php get('/users/:id', function($context) { }); ``` -### Nested +#### Nested ```php route('/prefix', $nestedApp); ``` -## Context +### Context ```php