Write intercepts the response body and modifies the base path
(b []byte)
| 211 | |
| 212 | // Write intercepts the response body and modifies the base path |
| 213 | func (w bodyTamper) Write(b []byte) (int, error) { |
| 214 | var m map[string]interface{} |
| 215 | err := json.Unmarshal(b, &m) |
| 216 | if err != nil { |
| 217 | return 0, err |
| 218 | } |
| 219 | m["basePath"] = "/api" |
| 220 | b, err = json.Marshal(m) |
| 221 | if err != nil { |
| 222 | return 0, err |
| 223 | } |
| 224 | return w.ResponseWriter.Write(b) |
| 225 | } |
| 226 | |
| 227 | func modifyBasePath(c *gin.Context) { |
| 228 | if !strings.HasSuffix(c.Request.URL.Path, "swagger/doc.json") { |
no outgoing calls
no test coverage detected