add Cloudflare R2 storage integration and update bug report handling
Some checks failed
Build & Publish Docker Image / build-and-push (push) Failing after 11s
Some checks failed
Build & Publish Docker Image / build-and-push (push) Failing after 11s
This commit is contained in:
@@ -5,13 +5,14 @@ import (
|
||||
"time"
|
||||
|
||||
"emly-api-go/internal/handlers"
|
||||
"emly-api-go/internal/storage"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/httprate"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
func registerBugReports(r chi.Router, db *sqlx.DB, dbName string) {
|
||||
func registerBugReports(r chi.Router, db *sqlx.DB, dbName string, s3conn *storage.S3Connector) {
|
||||
r.Route("/bug-reports", func(r chi.Router) {
|
||||
// API key only: submit a report and check count
|
||||
r.Group(func(r chi.Router) {
|
||||
@@ -19,7 +20,7 @@ func registerBugReports(r chi.Router, db *sqlx.DB, dbName string) {
|
||||
r.Use(httprate.LimitByIP(30, time.Minute))
|
||||
|
||||
r.Get("/count", handlers.GetReportsCount(db, dbName))
|
||||
r.Post("/", handlers.CreateBugReport(db, dbName))
|
||||
r.Post("/", handlers.CreateBugReport(db, dbName, s3conn))
|
||||
})
|
||||
|
||||
// API key + admin key: full read/write access
|
||||
@@ -32,10 +33,10 @@ func registerBugReports(r chi.Router, db *sqlx.DB, dbName string) {
|
||||
r.Get("/{id}", handlers.GetBugReportByID(db, dbName))
|
||||
r.Get("/{id}/status", handlers.GetReportStatusByID(db, dbName))
|
||||
r.Get("/{id}/files", handlers.GetReportFilesByReportID(db, dbName))
|
||||
r.Get("/{id}/files/{file_id}", handlers.GetReportFileByFileID(db, dbName))
|
||||
r.Get("/{id}/download", handlers.GetBugReportZipById(db, dbName))
|
||||
r.Get("/{id}/files/{file_id}", handlers.GetReportFileByFileID(db, dbName, s3conn))
|
||||
r.Get("/{id}/download", handlers.GetBugReportZipByID(db, dbName))
|
||||
r.Patch("/{id}/status", handlers.PatchBugReportStatus(db, dbName))
|
||||
r.Delete("/{id}", handlers.DeleteBugReportByID(db, dbName))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user