File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ .idea
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "github.com/speakeasy-api/speakeasy-auth-test-service/internal/responseHeaders"
4
5
"log"
5
6
"net/http"
6
7
@@ -16,6 +17,7 @@ func main() {
16
17
}).Methods (http .MethodGet )
17
18
r .HandleFunc ("/auth" , auth .HandleAuth ).Methods (http .MethodPost )
18
19
r .HandleFunc ("/requestbody" , requestbody .HandleRequestBody ).Methods (http .MethodPost )
20
+ r .HandleFunc ("/vendorjson" , responseHeaders .HandleVendorJsonResponseHeaders ).Methods (http .MethodGet )
19
21
20
22
log .Println ("Listening on :8080" )
21
23
if err := http .ListenAndServe (":8080" , r ); err != nil {
Original file line number Diff line number Diff line change
1
+ package responseHeaders
2
+
3
+ import (
4
+ "encoding/json"
5
+ "github.com/speakeasy-api/speakeasy-auth-test-service/internal/utils"
6
+ "io"
7
+ "net/http"
8
+ )
9
+
10
+ func HandleVendorJsonResponseHeaders (w http.ResponseWriter , r * http.Request ) {
11
+ body , err := io .ReadAll (r .Body )
12
+ if err != nil {
13
+ utils .HandleError (w , err )
14
+ return
15
+ }
16
+
17
+ var req interface {}
18
+ if err := json .Unmarshal (body , & req ); err != nil {
19
+ utils .HandleError (w , err )
20
+ return
21
+ }
22
+
23
+ w .Header ().Set ("Content-Type" , "application/vnd.api+json; charset=utf-8" )
24
+
25
+ if err := json .NewEncoder (w ).Encode (req ); err != nil {
26
+ utils .HandleError (w , err )
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments