File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
documentation/docs/guides Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,36 @@ import FlowChart from '@site/src/components/FlowChart';
4
4
5
5
Controllers are the main way to interact with the application. They are responsible for handling the requests and responses.
6
6
7
+
8
+
7
9
<FlowChart selected = " Controller" />
10
+
11
+ ## Controller types
12
+
13
+ ### Returning JSON
14
+
15
+ ``` go
16
+ func (c *fuego .ContextNoBody ) (MyResponse , error )
17
+ ```
18
+
19
+ Used when the request does not have a body. The response will be automatically serialized to JSON.
20
+
21
+ ```go
22
+ func (c *fuego.ContextWithBody[MyInput]) (MyResponse, error)
23
+ ```
24
+
25
+ Used when the request has a body.
26
+ Fuego will automatically parse the body and validate it using the input struct.
27
+
28
+ ### Returning HTML
29
+
30
+ ```go
31
+ func (c *fuego.ContextNoBody) (fuego.HTML, error)
32
+ ```
33
+
34
+ Some special interface return types are used by Fuego to return special responses.
35
+
36
+ - `fuego.HTML` is used to return HTML responses from `html/template`.
37
+ - `fuego.Templ` is used to return HTML responses from `a-h/templ`.
38
+ - `fuego.Gomponent` is used to return HTML responses from `maragudk/gomponent`.
39
+
You can’t perform that action at this time.
0 commit comments