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
29
apirequest/seed.go
Normal file
29
apirequest/seed.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package apirequest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"codeberg.org/vlbeaudoin/voki"
|
||||
"codeberg.org/vlbeaudoin/voki/request"
|
||||
"git.agecem.com/agecem/agecem-org/apiresponse"
|
||||
)
|
||||
|
||||
var _ request.Requester[apiresponse.V1SeedPOST] = V1SeedPOST{}
|
||||
|
||||
type V1SeedPOST struct{}
|
||||
|
||||
func NewV1SeedPOST() (request V1SeedPOST, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (r V1SeedPOST) Complete() bool { return true }
|
||||
|
||||
func (r V1SeedPOST) Request(v *voki.Voki) (response apiresponse.V1SeedPOST, err error) {
|
||||
if !r.Complete() {
|
||||
err = fmt.Errorf("Incomplete V1SeedPOST")
|
||||
return
|
||||
}
|
||||
|
||||
return response, v.UnmarshalIfComplete(http.MethodPost, "/v1/seed", nil, true, &response)
|
||||
}
|
29
apirequest/spec.go
Normal file
29
apirequest/spec.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package apirequest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"codeberg.org/vlbeaudoin/voki"
|
||||
"codeberg.org/vlbeaudoin/voki/request"
|
||||
"git.agecem.com/agecem/agecem-org/apiresponse"
|
||||
)
|
||||
|
||||
var _ request.Requester[apiresponse.V1SpecGET] = V1SpecGET{}
|
||||
|
||||
type V1SpecGET struct{}
|
||||
|
||||
func NewV1SpecGET() (request V1SpecGET, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (request V1SpecGET) Complete() bool { return true }
|
||||
|
||||
func (request V1SpecGET) Request(v *voki.Voki) (response apiresponse.V1SpecGET, err error) {
|
||||
if !request.Complete() {
|
||||
err = fmt.Errorf("Incomplete V1SpecGET")
|
||||
return
|
||||
}
|
||||
|
||||
return response, v.UnmarshalIfComplete(http.MethodGet, "/v1/spec", nil, true, &response)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue