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_modifier_handler.go
Normal file
34
backend/internal/handlers/material_modifier_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"
|
||||
)
|
||||
|
||||
// MaterialModifierHandler handles requests for material modifier lookup data.
|
||||
type MaterialModifierHandler struct {
|
||||
repo *repositories.MaterialModifierRepository
|
||||
}
|
||||
|
||||
// NewMaterialModifierHandler creates a MaterialModifierHandler with the given repository.
|
||||
func NewMaterialModifierHandler(repo *repositories.MaterialModifierRepository) *MaterialModifierHandler {
|
||||
return &MaterialModifierHandler{repo: repo}
|
||||
}
|
||||
|
||||
// List handles GET /api/modifiers — returns all material modifiers.
|
||||
func (h *MaterialModifierHandler) List(w http.ResponseWriter, r *http.Request) {
|
||||
modifiers, err := h.repo.GetAll(r.Context())
|
||||
if err != nil {
|
||||
slog.Error("failed to list modifiers", "error", err)
|
||||
writeJSON(w, http.StatusInternalServerError, dtos.ErrorResponse{
|
||||
Error: "internal server error",
|
||||
Code: http.StatusInternalServerError,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, dtos.SingleResponse{Data: modifiers})
|
||||
}
|
||||
Reference in New Issue
Block a user