@@ -16,8 +16,93 @@ It's what's missing between applications and infrastructure automation.
16
16
17
17
Oh, and it supports basically any language, like JavaScript, TypeScript, Python, Go, you name it.
18
18
19
- <div className = " " >
20
- <Libraries minimal />
19
+ <div className = " flex items-center flex-col gap-4 mt-10" >
20
+
21
+ <div className = " not-prose" >
22
+ <LanguageSwitch />
23
+ </div >
24
+
25
+ <div className = " max-w-xl w-full" >
26
+
27
+ <CodeSwitcher enableTransitions className = " xl:max-h-[300px] w-full" >
28
+
29
+ ``` javascript !! title:services/api.js
30
+ import { api } from ' @nitric/sdk'
31
+
32
+ const main = api (' main' )
33
+
34
+ main .get (' /hello/:name' , async ({ req, res }) => {
35
+ const { name } = req .params
36
+ ctx .res .body = ` Hello ${ name} `
37
+ })
38
+ ```
39
+
40
+ ``` typescript !! title:services/api.ts
41
+ import { api } from ' @nitric/sdk'
42
+
43
+ const main = api (' main' )
44
+
45
+ main .get (' /hello/:name' , async ({ req , res }) => {
46
+ const { name } = req .params
47
+ ctx .res .body = ` Hello ${name } `
48
+ })
49
+ ```
50
+
51
+ ``` python !! title:services/example.py
52
+ from nitric.application import Nitric
53
+ from nitric.resources import api
54
+ from nitric.context import HttpContext
55
+
56
+ main = api(" main" )
57
+
58
+ @main.get (" /hello/:name" )
59
+ async def hello_world (ctx : HttpContext):
60
+ name = ctx.req.params[' name' ]
61
+ ctx.res.body = f " Hello { name} "
62
+
63
+ Nitric.run()
64
+ ```
65
+
66
+ ``` go !! title:services/example/main.go
67
+ // !collapse(1:5) collapsed
68
+ import (
69
+ " context"
70
+
71
+ " github.com/nitrictech/go-sdk/nitric"
72
+ " github.com/nitrictech/go-sdk/nitric/apis"
73
+ )
74
+
75
+ func main () {
76
+ api := nitric.NewApi (" main" )
77
+
78
+ api.Get (" /hello/:name" , func (ctx *apis.Ctx ) {
79
+ name := ctx.Request .PathParams ()[" name" ]
80
+ ctx.Response .Body = []byte (fmt.Sprintf (" Hello %s " , name))
81
+ })
82
+
83
+ nitric.Run ()
84
+ }
85
+ ```
86
+
87
+ ``` dart !! title:services/example.dart
88
+ import 'package:nitric_sdk/nitric.dart';
89
+
90
+ void main() {
91
+ final main = Nitric.api('main');
92
+
93
+ main.get('/hello/:name', (ctx) async {
94
+ final name = ctx.req.pathParams["name"]!;
95
+ ctx.res.body = "Hello $name";
96
+
97
+ return ctx;
98
+ });
99
+ }
100
+ ```
101
+
102
+ </CodeSwitcher >
103
+
104
+ </div >
105
+
21
106
</div >
22
107
23
108
If you're familiar Nitric already, you might want to jump to the [ Installation] ( /getting-started/installation ) , [ Guides] ( /guides ) or [ Resources] ( /apis ) sections. Otherwise, keep reading to learn more about Nitric.
0 commit comments