feat(api): add pave spec to route /v1/spec and add seed to it
Exposes the API spec in pave format, which intends to show information about all API routes. Also pave V1SeedPOST and V1SpecGET
This commit is contained in:
parent
0c7009b16b
commit
7bf489315e
15 changed files with 152 additions and 25 deletions
|
@ -2,27 +2,19 @@ package apiresponse
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"codeberg.org/vlbeaudoin/voki/response"
|
||||
)
|
||||
|
||||
type Responder interface {
|
||||
Respond() Responder
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
StatusCode int `json:"status_code"`
|
||||
Message string
|
||||
Error string
|
||||
}
|
||||
|
||||
func (r Response) Respond() Responder {
|
||||
return r
|
||||
response.ResponseWithError
|
||||
}
|
||||
|
||||
type SimpleResponse struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
func (r SimpleResponse) Respond() Responder {
|
||||
func (r SimpleResponse) Respond() response.Responder {
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package apiresponse
|
||||
|
||||
type V1BucketListResponse struct {
|
||||
type V1BucketList struct {
|
||||
Response
|
||||
Data struct {
|
||||
Buckets map[string]string
|
||||
}
|
||||
}
|
||||
|
||||
type V1BucketReadResponse struct {
|
||||
type V1BucketRead struct {
|
||||
Response
|
||||
Data struct {
|
||||
Keys []string
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package apiresponse
|
||||
|
||||
type V1DocumentCreateResponse struct {
|
||||
type V1DocumentCreate struct {
|
||||
Response
|
||||
Data struct {
|
||||
Bucket string
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package apiresponse
|
||||
|
||||
type V1SeedResponse struct {
|
||||
type V1SeedPOST struct {
|
||||
Response
|
||||
Data struct {
|
||||
Buckets []string
|
||||
|
|
8
apiresponse/spec.go
Normal file
8
apiresponse/spec.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
package apiresponse
|
||||
|
||||
type V1SpecGET struct {
|
||||
Response
|
||||
Data struct {
|
||||
Spec string
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue