72 lines
1.2 KiB
Go
72 lines
1.2 KiB
Go
package apiresponse
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.agecem.com/agecem/agecem-org/models"
|
|
)
|
|
|
|
type Responder interface {
|
|
Respond() Responder
|
|
}
|
|
|
|
type Response struct {
|
|
StatusCode int `json:"status_code"`
|
|
Message string
|
|
Error string
|
|
}
|
|
|
|
func (r Response) Respond() Responder {
|
|
return r
|
|
}
|
|
|
|
type SimpleResponse struct {
|
|
Message string
|
|
}
|
|
|
|
func (r SimpleResponse) Respond() Responder {
|
|
return r
|
|
}
|
|
|
|
func NotFoundResponse() (int, SimpleResponse) {
|
|
return http.StatusNotFound, SimpleResponse{
|
|
Message: "Not Found",
|
|
}
|
|
}
|
|
|
|
func NotImplementedResponse() (int, SimpleResponse) {
|
|
return http.StatusNotImplemented, SimpleResponse{
|
|
Message: "Not Implemented",
|
|
}
|
|
}
|
|
|
|
func InternalServerErrorResponse() (int, SimpleResponse) {
|
|
return http.StatusInternalServerError, SimpleResponse{
|
|
Message: "Internal Server Error",
|
|
}
|
|
}
|
|
|
|
type HandleAdminDocumentsUploadResponse struct {
|
|
Response
|
|
Data struct {
|
|
Buckets []models.Bucket
|
|
}
|
|
}
|
|
|
|
type HandleDocumentationResponse struct {
|
|
Response
|
|
Data struct {
|
|
Buckets []models.Bucket
|
|
}
|
|
}
|
|
|
|
type UploadDocumentResponse struct {
|
|
Response
|
|
Data UploadDocumentResponseData
|
|
}
|
|
|
|
type UploadDocumentResponseData struct {
|
|
Bucket string
|
|
Object string
|
|
Size float64
|
|
}
|