2023-10-24 17:39:15 -04:00
|
|
|
package apiresponse
|
2023-08-19 15:49:57 -04:00
|
|
|
|
2023-10-24 17:39:15 -04:00
|
|
|
import (
|
|
|
|
"net/http"
|
2023-08-23 15:43:10 -04:00
|
|
|
|
2023-11-20 15:13:42 -05:00
|
|
|
"codeberg.org/vlbeaudoin/voki/response"
|
|
|
|
)
|
2023-08-19 15:49:57 -04:00
|
|
|
|
|
|
|
type Response struct {
|
2023-11-20 15:13:42 -05:00
|
|
|
response.ResponseWithError
|
2023-08-19 15:49:57 -04:00
|
|
|
}
|
|
|
|
|
2023-08-22 15:24:57 -04:00
|
|
|
type SimpleResponse struct {
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2023-11-20 15:13:42 -05:00
|
|
|
func (r SimpleResponse) Respond() response.Responder {
|
2023-08-22 15:24:57 -04:00
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2023-08-23 16:01:57 -04:00
|
|
|
func NotFoundResponse() (int, SimpleResponse) {
|
|
|
|
return http.StatusNotFound, SimpleResponse{
|
2023-08-22 15:24:57 -04:00
|
|
|
Message: "Not Found",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-23 15:43:10 -04:00
|
|
|
func NotImplementedResponse() (int, SimpleResponse) {
|
|
|
|
return http.StatusNotImplemented, SimpleResponse{
|
|
|
|
Message: "Not Implemented",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-24 17:39:15 -04:00
|
|
|
func InternalServerErrorResponse() (int, SimpleResponse) {
|
|
|
|
return http.StatusInternalServerError, SimpleResponse{
|
|
|
|
Message: "Internal Server Error",
|
|
|
|
}
|
|
|
|
}
|