readJavascript reads a javascript function from a request body.
()
| 1367 | |
| 1368 | // readJavascript reads a javascript function from a request body. |
| 1369 | func (h *handler) readJavascript() (string, error) { |
| 1370 | // Performs the Content-Type validation and Content-Encoding check. |
| 1371 | input, err := processContentEncoding(h.rq.Header, h.requestBody, "application/javascript") |
| 1372 | if err != nil { |
| 1373 | return "", err |
| 1374 | } |
| 1375 | |
| 1376 | defer func() { _ = input.Close() }() |
| 1377 | jsBytes, err := io.ReadAll(input) |
| 1378 | if err != nil { |
| 1379 | return "", err |
| 1380 | } |
| 1381 | |
| 1382 | return string(jsBytes), nil |
| 1383 | } |
| 1384 | |
| 1385 | // readSanitizeJSONInto reads and sanitizes a JSON request body and returns raw bytes and DbConfig. |
| 1386 | // Expands environment variables (if any) referenced in the config. |
no test coverage detected