fix: update voki requests/responses à v3
This commit is contained in:
parent
b4529e8102
commit
7bc4eed8ae
20 changed files with 169 additions and 175 deletions
|
@ -1,37 +1,19 @@
|
|||
package apiresponse
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"codeberg.org/vlbeaudoin/voki/response"
|
||||
"codeberg.org/vlbeaudoin/voki/v3"
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
response.ResponseWithError
|
||||
type APIResponse struct {
|
||||
voki.MessageResponse
|
||||
statusCode int
|
||||
Error string
|
||||
}
|
||||
|
||||
type SimpleResponse struct {
|
||||
Message string
|
||||
func (R APIResponse) StatusCode() int {
|
||||
return R.statusCode
|
||||
}
|
||||
|
||||
func (r SimpleResponse) Respond() response.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",
|
||||
}
|
||||
func (R *APIResponse) SetStatusCode(code int) {
|
||||
R.statusCode = code
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package apiresponse
|
||||
|
||||
type V1BucketsGET struct {
|
||||
Response
|
||||
APIResponse
|
||||
Data struct {
|
||||
Buckets map[string]string
|
||||
}
|
||||
}
|
||||
|
||||
type V1BucketGET struct {
|
||||
Response
|
||||
APIResponse
|
||||
Data struct {
|
||||
Keys []string
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ type DataDocument struct {
|
|||
}
|
||||
|
||||
type V1DocumentsPOST struct {
|
||||
Response
|
||||
APIResponse
|
||||
Data struct {
|
||||
Bucket string
|
||||
Documents []DataDocument
|
||||
|
@ -15,7 +15,7 @@ type V1DocumentsPOST struct {
|
|||
|
||||
// Deprecated: Use V1DocumentsPOST instead
|
||||
type V1DocumentPOST struct {
|
||||
Response
|
||||
APIResponse
|
||||
Data struct {
|
||||
Bucket string
|
||||
DataDocument
|
||||
|
@ -23,11 +23,11 @@ type V1DocumentPOST struct {
|
|||
}
|
||||
|
||||
type V1DocumentDELETE struct {
|
||||
Response
|
||||
APIResponse
|
||||
}
|
||||
|
||||
type V1DocumentKeyPUT struct {
|
||||
Response
|
||||
APIResponse
|
||||
Data struct {
|
||||
Bucket string
|
||||
Key string
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package apiresponse
|
||||
|
||||
type V1SeedPOST struct {
|
||||
Response
|
||||
APIResponse
|
||||
Data struct {
|
||||
Buckets []string
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package apiresponse
|
||||
|
||||
type V1SpecGET struct {
|
||||
Response
|
||||
APIResponse
|
||||
Data struct {
|
||||
Spec string
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue