You've already forked reloading-manager
No changes made
This commit is contained in:
42
backend/handlers/response.go
Normal file
42
backend/handlers/response.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const DateFormat = "2006-01-02 15:04:05"
|
||||
|
||||
type Response[T any] struct {
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Payload T `json:"payload"`
|
||||
}
|
||||
|
||||
func BadRequest(c echo.Context, message string) error {
|
||||
return c.JSON(http.StatusBadRequest, Response[string]{
|
||||
Status: http.StatusText(http.StatusBadRequest),
|
||||
Message: message,
|
||||
})
|
||||
}
|
||||
|
||||
func NotFound(c echo.Context, message string) error {
|
||||
return c.JSON(http.StatusNotFound, Response[string]{
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Message: message,
|
||||
})
|
||||
}
|
||||
|
||||
type Manufacturer struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type Powder struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Meta string `json:"meta"`
|
||||
Photo string `json:"photo,omitempty"`
|
||||
Manufacturer Manufacturer `json:"manufacturer"`
|
||||
}
|
||||
Reference in New Issue
Block a user