refactor(media): replace hand-rolled SigV4 with maintained minio-go SDK; add /admin/media/upload endpoint
This commit is contained in:
@@ -37,25 +37,16 @@ func main() {
|
||||
log.Printf("loaded %d articles across %d subjects", len(c.Articles), len(c.Subjects))
|
||||
|
||||
s := NewSite(c)
|
||||
// media proxy config (Garage S3)
|
||||
s.Media = &S3MediaClient{
|
||||
Endpoint: os.Getenv("KONTRA_S3_ENDPOINT"),
|
||||
Bucket: os.Getenv("KONTRA_S3_BUCKET"),
|
||||
Key: os.Getenv("KONTRA_S3_KEY"),
|
||||
Secret: os.Getenv("KONTRA_S3_SECRET"),
|
||||
Client: http.Client{},
|
||||
}
|
||||
if s.Media.Endpoint == "" {
|
||||
s.Media.Endpoint = "http://127.0.0.1:3900"
|
||||
}
|
||||
if s.Media.Bucket == "" {
|
||||
s.Media.Bucket = "kontra-day"
|
||||
}
|
||||
// media (Garage S3 via minio-go SDK)
|
||||
s.Media = NewMediaClient()
|
||||
|
||||
// Routes — register specific paths BEFORE the catch-all.
|
||||
http.HandleFunc("/media/{path...}", func(w http.ResponseWriter, r *http.Request) {
|
||||
s.media(w, r, r.PathValue("path"))
|
||||
})
|
||||
http.HandleFunc("/admin/media/upload", func(w http.ResponseWriter, r *http.Request) {
|
||||
s.mediaUpload(w, r)
|
||||
})
|
||||
http.HandleFunc("/subjects/{slug}", func(w http.ResponseWriter, r *http.Request) {
|
||||
s.subject(w, r, r.PathValue("slug"))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user