Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 6e8c7ca

Browse files
move route middleware to route definition
1 parent 9a69d5c commit 6e8c7ca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pages/apis.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ func validate(ctx *handler.HttpContext, next handler.HttpHandler) (*handler.Http
621621

622622
```dart
623623
Future<HttpContext> validate(HttpContext ctx) async {
624-
if (ctx.req.headers.containsKey("content-type")) {
624+
if (!ctx.req.headers.containsKey("Content-Type")) {
625625
ctx.res.status = 400;
626626
ctx.res.body = "header Content-Type is required";
627627
@@ -783,7 +783,7 @@ final customersApi = Nitric.api("customers");
783783
customersApi.get("/customers", getAllCustomers, middlewares: [logRequest, validate]);
784784
785785
// Inline using .route()
786-
customersApi.route("/customers").get(getAllCustomers, middlewares: [logRequest, validate]);
786+
customersApi.route("/customers", middlewares: [logRequest, validate]).get(getAllCustomers);
787787
```
788788

789789
</CodeGroup>

0 commit comments

Comments
 (0)