mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 06:49:40 +02:00
Replaces the NestJS mana-search service with a Go implementation for lower resource usage and faster startup. All 7 API endpoints are 1:1 compatible (search, extract, bulk extract, engines, health, metrics, cache clear). Uses go-readability for content extraction and html-to-markdown for Markdown conversion. Redis cache with graceful degradation, Prometheus metrics, and structured JSON logging. Binary: 22 MB vs ~200+ MB node_modules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 lines
511 B
Go
24 lines
511 B
Go
package handler
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func writeJSON(w http.ResponseWriter, status int, data any) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(status)
|
|
json.NewEncoder(w).Encode(data)
|
|
}
|
|
|
|
func writeError(w http.ResponseWriter, status int, message string) {
|
|
writeJSON(w, status, map[string]any{
|
|
"success": false,
|
|
"error": map[string]any{
|
|
"statusCode": status,
|
|
"message": message,
|
|
"timestamp": time.Now().UTC().Format(time.RFC3339),
|
|
},
|
|
})
|
|
}
|