aboutsummaryrefslogtreecommitdiff
path: root/cmd/parser/main.go
diff options
context:
space:
mode:
authorSamuel Johnson <[email protected]>2025-11-25 20:52:35 -0500
committerSamuel Johnson <[email protected]>2025-11-25 20:52:35 -0500
commit44d6620b32f31c04663c9e08a1c3954273230ee8 (patch)
treea87cf977313ec95f050d7cdbbebd8bdae7c00ab2 /cmd/parser/main.go
parent12602302f28478a9e4ef91e66f68347a4d76f8a6 (diff)
Tidy the code
Diffstat (limited to 'cmd/parser/main.go')
-rw-r--r--cmd/parser/main.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/cmd/parser/main.go b/cmd/parser/main.go
index 44fca42..0ef8b4d 100644
--- a/cmd/parser/main.go
+++ b/cmd/parser/main.go
@@ -35,7 +35,7 @@ func mdServe(w http.ResponseWriter, r *http.Request) {
writeErr(w, http.StatusMethodNotAllowed, "Method Not Allowed")
return
}
-
+
err := r.ParseMultipartForm(4 << 20)
if err != nil {
writeErr(w, http.StatusUnprocessableEntity, fmt.Sprintf("Failed to retrieve form data: %v", err))
@@ -48,25 +48,25 @@ func mdServe(w http.ResponseWriter, r *http.Request) {
userId := r.Form.Get("user_id")
shouldCreateShort := len(md) > 255
-
+
err = mdParser.Convert([]byte(md), &longBuf)
if err != nil {
writeErr(w, http.StatusUnprocessableEntity, fmt.Sprintf("Failed to compile markdown into html: %v", err))
return
}
-
+
var shortMd string
if shouldCreateShort {
shortMd = md[0:249]
err = mdParser.Convert([]byte(shortMd), &shortBuf)
-
+
if err != nil {
writeErr(w, http.StatusUnprocessableEntity, fmt.Sprintf("Failed to compile markdown into html: %v", err))
return
}
}
- ctx, cancel := context.WithTimeout(r.Context(), 5 * time.Second)
+ ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
defer cancel()
tx, err := db.BeginTx(ctx, nil)
@@ -155,7 +155,7 @@ func main() {
}
srv := &http.Server{
- Addr: fmt.Sprintf(":%d", appPort),
+ Addr: fmt.Sprintf(":%d", appPort),
Handler: router,
}