CUB-130: Build Add/Edit Filament form with backend endpoints for finishes and modifiers
All checks were successful
Dev Build / build-test (pull_request) Successful in 2m39s
All checks were successful
Dev Build / build-test (pull_request) Successful in 2m39s
This commit is contained in:
34
backend/internal/handlers/material_finish_handler.go
Normal file
34
backend/internal/handlers/material_finish_handler.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/CubeCraft-Creations/Extrudex/backend/internal/dtos"
|
||||
"github.com/CubeCraft-Creations/Extrudex/backend/internal/repositories"
|
||||
)
|
||||
|
||||
// MaterialFinishHandler handles requests for material finish lookup data.
|
||||
type MaterialFinishHandler struct {
|
||||
repo *repositories.MaterialFinishRepository
|
||||
}
|
||||
|
||||
// NewMaterialFinishHandler creates a MaterialFinishHandler with the given repository.
|
||||
func NewMaterialFinishHandler(repo *repositories.MaterialFinishRepository) *MaterialFinishHandler {
|
||||
return &MaterialFinishHandler{repo: repo}
|
||||
}
|
||||
|
||||
// List handles GET /api/finishes — returns all material finishes.
|
||||
func (h *MaterialFinishHandler) List(w http.ResponseWriter, r *http.Request) {
|
||||
finishes, err := h.repo.GetAll(r.Context())
|
||||
if err != nil {
|
||||
slog.Error("failed to list finishes", "error", err)
|
||||
writeJSON(w, http.StatusInternalServerError, dtos.ErrorResponse{
|
||||
Error: "internal server error",
|
||||
Code: http.StatusInternalServerError,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, dtos.SingleResponse{Data: finishes})
|
||||
}
|
||||
Reference in New Issue
Block a user