MCPcopy Index your code
hub / github.com/writefreely/writefreely / handleRenderMarkdown

Function handleRenderMarkdown

postrender.go:339–363  ·  view source on GitHub ↗
(app *App, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

337}
338
339func 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}

Callers

nothing calls this directly

Calls 2

IsJSONFunction · 0.85
applyMarkdownFunction · 0.85

Tested by

no test coverage detected