(app *App, w http.ResponseWriter, r *http.Request)
| 337 | } |
| 338 | |
| 339 | func handleRenderMarkdown(app *App, w http.ResponseWriter, r *http.Request) error { |
| 340 | if !IsJSON(r) { |
| 341 | return impart.HTTPError{Status: http.StatusUnsupportedMediaType, Message: "Markdown API only supports JSON requests"} |
| 342 | } |
| 343 | |
| 344 | in := struct { |
| 345 | CollectionURL string `json:"collection_url"` |
| 346 | RawBody string `json:"raw_body"` |
| 347 | }{} |
| 348 | |
| 349 | decoder := json.NewDecoder(r.Body) |
| 350 | err := decoder.Decode(&in) |
| 351 | if err != nil { |
| 352 | log.Error("Couldn't parse markdown JSON request: %v", err) |
| 353 | return ErrBadJSON |
| 354 | } |
| 355 | |
| 356 | out := struct { |
| 357 | Body string `json:"body"` |
| 358 | }{ |
| 359 | Body: applyMarkdown([]byte(in.RawBody), in.CollectionURL, app.cfg), |
| 360 | } |
| 361 | |
| 362 | return impart.WriteSuccess(w, out, http.StatusOK) |
| 363 | } |
nothing calls this directly
no test coverage detected