You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-delete.mdx
+25-22Lines changed: 25 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,53 +71,56 @@ Application.Run();
71
71
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
72
72
73
73
```csharp
74
-
usingNitric.Sdk;
74
+
usingNitric.Sdk.Service;
75
+
usingApplication=Nitric.Sdk.Nitric;
75
76
76
-
varapi=Nitric.Api("main");
77
+
varapi=Application.Api("main");
77
78
78
79
api.Delete("/hello/:userId",
79
-
(context, next) => {
80
-
varuser=context.Req.PathParams["userId"];
80
+
newMiddleware<HttpContext>[] {
81
+
(context, next) => {
82
+
varuser=context.Req.PathParams["userId"];
81
83
82
-
// Validate the user identity
83
-
if (user!="1234")
84
-
{
85
-
context.Res.Text($"User {user} is unauthorised");
86
-
context.Res.Status=403;
84
+
// Validate the user identity
85
+
if (user!="1234")
86
+
{
87
+
context.Res.Text($"User {user} is unauthorised");
88
+
context.Res.Status=403;
87
89
88
-
// Return prematurely to end the middleware chain.
89
-
returncontext;
90
-
}
90
+
// Return prematurely to end the middleware chain.
91
+
returncontext;
92
+
}
91
93
92
-
// Call next to continue the middleware chain.
93
-
returnnext(context);
94
-
}, (context, next) => {
95
-
varuser=context.Req.PathParams["userId"];
94
+
// Call next to continue the middleware chain.
95
+
returnnext(context);
96
+
}, (context, next) => {
97
+
varuser=context.Req.PathParams["userId"];
96
98
97
-
context.Res.Text($"Deleting {user}");
99
+
context.Res.Text($"Deleting {user}");
98
100
99
-
returnnext(context);
101
+
returnnext(context);
102
+
}
100
103
}
101
104
);
102
105
103
-
Nitric.Run();
106
+
Application.Run();
104
107
```
105
108
106
109
### Access the request body
107
110
108
111
The DELETE request body is accessible from the `context.Req` object.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-get.mdx
+19-16Lines changed: 19 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,32 +71,35 @@ Application.Run();
71
71
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
72
72
73
73
```csharp
74
+
usingNitric.Sdk.Service;
74
75
usingApplication=Nitric.Sdk.Nitric;
75
76
76
77
varapi=Application.Api("main");
77
78
78
79
api.Get("/hello/:userId",
79
-
(context, next) => {
80
-
varuser=context.Req.PathParams["userId"];
80
+
newMiddleware<HttpContext>[] {
81
+
(context, next) => {
82
+
varuser=context.Req.PathParams["userId"];
81
83
82
-
// Validate the user identity
83
-
if (user!="1234")
84
-
{
85
-
context.Res.Text($"User {user} is unauthorised");
86
-
context.Res.Status=403;
84
+
// Validate the user identity
85
+
if (user!="1234")
86
+
{
87
+
context.Res.Text($"User {user} is unauthorised");
88
+
context.Res.Status=403;
87
89
88
-
// Return prematurely to end the middleware chain.
89
-
returncontext;
90
-
}
90
+
// Return prematurely to end the middleware chain.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-patch.mdx
+19-16Lines changed: 19 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,32 +71,35 @@ Application.Run();
71
71
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
72
72
73
73
```csharp
74
+
usingNitric.Sdk.Service;
74
75
usingApplication=Nitric.Sdk.Nitric;
75
76
76
77
varapi=Application.Api("main");
77
78
78
79
api.Patch("/hello/:userId",
79
-
(context, next) => {
80
-
varuser=context.Req.PathParams["userId"];
80
+
newMiddleware<HttpContext>[] {
81
+
(context, next) => {
82
+
varuser=context.Req.PathParams["userId"];
81
83
82
-
// Validate the user identity
83
-
if (user!="1234")
84
-
{
85
-
context.Res.Text($"User {user} is unauthorised");
86
-
context.Res.Status=403;
84
+
// Validate the user identity
85
+
if (user!="1234")
86
+
{
87
+
context.Res.Text($"User {user} is unauthorised");
88
+
context.Res.Status=403;
87
89
88
-
// Return prematurely to end the middleware chain.
89
-
returncontext;
90
-
}
90
+
// Return prematurely to end the middleware chain.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-post.mdx
+19-16Lines changed: 19 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,32 +71,35 @@ Application.Run();
71
71
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
72
72
73
73
```csharp
74
+
usingNitric.Sdk.Service;
74
75
usingApplication=Nitric.Sdk.Nitric;
75
76
76
77
varapi=Application.Api("main");
77
78
78
79
api.Post("/hello/:userId",
79
-
(context, next) => {
80
-
varuser=context.Req.PathParams["userId"];
80
+
newMiddleware<HttpContext>[] {
81
+
(context, next) => {
82
+
varuser=context.Req.PathParams["userId"];
81
83
82
-
// Validate the user identity
83
-
if (user!="1234")
84
-
{
85
-
context.Res.Text($"User {user} is unauthorised");
86
-
context.Res.Status=403;
84
+
// Validate the user identity
85
+
if (user!="1234")
86
+
{
87
+
context.Res.Text($"User {user} is unauthorised");
88
+
context.Res.Status=403;
87
89
88
-
// Return prematurely to end the middleware chain.
89
-
returncontext;
90
-
}
90
+
// Return prematurely to end the middleware chain.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-put.mdx
+19-16Lines changed: 19 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,32 +71,35 @@ Application.Run();
71
71
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
72
72
73
73
```csharp
74
+
usingNitric.Sdk.Service;
74
75
usingApplication=Nitric.Sdk.Nitric;
75
76
76
77
varapi=Application.Api("main");
77
78
78
79
api.Put("/hello/:userId",
79
-
(context, next) => {
80
-
varuser=context.Req.PathParams["userId"];
80
+
newMiddleware<HttpContext>[] {
81
+
(context, next) => {
82
+
varuser=context.Req.PathParams["userId"];
81
83
82
-
// Validate the user identity
83
-
if (user!="1234")
84
-
{
85
-
context.Res.Text($"User {user} is unauthorised");
86
-
context.Res.Status=403;
84
+
// Validate the user identity
85
+
if (user!="1234")
86
+
{
87
+
context.Res.Text($"User {user} is unauthorised");
88
+
context.Res.Status=403;
87
89
88
-
// Return prematurely to end the middleware chain.
89
-
returncontext;
90
-
}
90
+
// Return prematurely to end the middleware chain.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-route-all.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,11 +83,13 @@ Application.Run();
83
83
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-route-delete.mdx
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,11 +68,13 @@ Application.Run();
68
68
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-route-get.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,11 +68,13 @@ Application.Run();
68
68
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
Copy file name to clipboardExpand all lines: docs/reference/csharp/api/api-route-patch.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,11 +68,13 @@ Application.Run();
68
68
When multiple functions are provided they will be called as a chain. If one succeeds, it will move on to the next. This allows middleware to be composed into more complex handlers.
0 commit comments