File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
internal/readonlywriteonly Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ func main() {
32
32
r .HandleFunc ("/optional" , acceptHeaders .HandleAcceptHeaderMultiplexing ).Methods (http .MethodGet )
33
33
r .HandleFunc ("/readonlyorwriteonly" , readonlywriteonly .HandleReadOrWrite ).Methods (http .MethodPost )
34
34
r .HandleFunc ("/readonlyandwriteonly" , readonlywriteonly .HandleReadAndWrite ).Methods (http .MethodPost )
35
+ r .HandleFunc ("/writeonlyoutput" , readonlywriteonly .HandleWriteOnlyOutput ).Methods (http .MethodPost )
35
36
36
37
log .Println ("Listening on :8080" )
37
38
if err := http .ListenAndServe (":8080" , r ); err != nil {
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ type BasicObject struct {
14
14
Num float64 `json:"num"`
15
15
}
16
16
17
+ type WriteOnlyOutputObject struct {}
18
+
17
19
type InputObject struct {
18
20
Num1 int64 `json:"num1"`
19
21
Num2 int64 `json:"num2"`
@@ -73,3 +75,23 @@ func HandleReadAndWrite(w http.ResponseWriter, r *http.Request) {
73
75
utils .HandleError (w , err )
74
76
}
75
77
}
78
+
79
+ func HandleWriteOnlyOutput (w http.ResponseWriter , r * http.Request ) {
80
+ body , err := io .ReadAll (r .Body )
81
+ if err != nil {
82
+ utils .HandleError (w , err )
83
+ return
84
+ }
85
+
86
+ var req InputObject
87
+ if err := json .Unmarshal (body , & req ); err != nil {
88
+ utils .HandleError (w , err )
89
+ return
90
+ }
91
+
92
+ w .Header ().Set ("Content-Type" , "application/json; charset=UTF-8" )
93
+
94
+ if err := json .NewEncoder (w ).Encode (WriteOnlyOutputObject {}); err != nil {
95
+ utils .HandleError (w , err )
96
+ }
97
+ }
You can’t perform that action at this time.
0 commit comments