File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -45,9 +45,23 @@ func post(w http.ResponseWriter, r *http.Request) {
4545 }
4646
4747 fmt .Println (response )
48+ type RespObject struct {
49+ Data []interface {}
50+ }
51+ respObject := RespObject {response }
52+ data , err := json .Marshal (respObject )
53+ if err != nil {
54+ fmt .Println (err )
55+ }
56+ fmt .Println ("" , data )
57+
58+ w .Header ().Set ("Content-Type" , "application/json" )
59+ w .WriteHeader (http .StatusOK )
60+ w .Write (data )
61+ // var res map[string]interface{}
62+ // json.Marshal(&response, &res)
4863
49- w .WriteHeader (http .StatusCreated )
50- w .Write ([]byte (`{"message": "post called"}` ))
64+ // w.Write([]byte(`{"message": "post called"}`))
5165}
5266
5367func get (w http.ResponseWriter , r * http.Request ) {
@@ -96,6 +110,7 @@ func handleRequests() {
96110 api .HandleFunc ("" , notFound )
97111 api .HandleFunc ("/user/{userID}/comment/{commentID}" , withParams ).Methods (http .MethodGet )
98112
113+ fmt .Println ("Server started" )
99114 log .Fatal (http .ListenAndServe (":8080" , r ))
100115}
101116
You can’t perform that action at this time.
0 commit comments