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.
If you need to put all the routes in your api below a shared base path, you can do that with the `BaseRoute` option. In this example we ensure all routes start with `/api/v1/` before the route specific path.
85
90
86
91
```csharp
87
-
usingApplication=Nitric.Sdk.Application;
92
+
usingApplication=Nitric.Sdk.Nitric;
88
93
usingNitric.Sdk.Resource;
89
94
90
95
varapi=Application.Api("main", newApiOptions(
91
-
BaseRoute: "/api/v1"
96
+
basePath: "/api/v1"
92
97
));
93
98
99
+
// Define API routes
100
+
api.Get("/example", (ctx) =>
101
+
{
102
+
ctx.Res.Text("Hello World!");
103
+
returnctx;
104
+
});
105
+
94
106
Application.Run();
95
107
```
96
108
97
109
### Apply JWT authentication to an API
98
110
99
111
```csharp
100
112
usingApplication=Nitric.Sdk.Nitric;
101
-
usingSystem.Collections.Generic;
102
113
usingNitric.Sdk.Resource;
114
+
usingSystem.Collections.Generic;
115
+
116
+
// Define security configuration
117
+
varsecurityOptions=newOidcOptions[]
118
+
{
119
+
newOidcOptions(
120
+
name: "user",
121
+
audiences: ["YOUR_AUDIENCES"],
122
+
issuer: "https://example-issuer.com",
123
+
// Optionally apply required scopes to this api
124
+
// in this case users will require the products:read scope to access the API
0 commit comments