mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
19
internal/api/api_response.go
Normal file
19
internal/api/api_response.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package api
|
||||
|
||||
import "net/http"
|
||||
|
||||
// Response represents a server status response.
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Err string `json:"error,omitempty"`
|
||||
Msg string `json:"message,omitempty"`
|
||||
Details string `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
// NewResponse creates a new server status response.
|
||||
func NewResponse(code int, err error, details string) Response {
|
||||
if err == nil {
|
||||
return Response{Code: http.StatusOK, Msg: "OK", Details: details}
|
||||
}
|
||||
return Response{Code: code, Err: err.Error(), Details: details}
|
||||
}
|
||||
Reference in New Issue
Block a user