Déplacer déclarations de route à pave pour API spec autogénérée #176

Merged
vlbeaudoin merged 17 commits from feature/pave into main 2023-11-20 17:05:41 -05:00
5 changed files with 19 additions and 19 deletions
Showing only changes of commit 8e40050f81 - Show all commits

View file

@ -101,7 +101,7 @@ func (a *API) UploadDocument(bucket string, file_header *multipart.FileHeader) (
return response, err return response, err
} }
func (a *API) ListBuckets() (response apiresponse.V1BucketList, err error) { func (a *API) ListBuckets() (response apiresponse.V1BucketsGET, err error) {
return response, a.Voki.Unmarshal(http.MethodGet, "/v1/bucket", nil, true, &response) return response, a.Voki.Unmarshal(http.MethodGet, "/v1/bucket", nil, true, &response)
} }

View file

@ -56,9 +56,9 @@ func (h *V1Handler) HandleV1Seed(c echo.Context) error {
return c.JSON(response.StatusCode, response) return c.JSON(response.StatusCode, response)
} }
// HandleV1BucketList affiche les buckets permis par server.documents.buckets, qui existent. // V1BucketsGET affiche les buckets permis par server.documents.buckets, qui existent.
func (h *V1Handler) HandleV1BucketList(c echo.Context) error { func (h *V1Handler) V1BucketsGET(c echo.Context) error {
var response apiresponse.V1BucketList var response apiresponse.V1BucketsGET
var buckets = make(map[string]string) var buckets = make(map[string]string)

View file

@ -1,6 +1,6 @@
package apiresponse package apiresponse
type V1BucketList struct { type V1BucketsGET struct {
Response Response
Data struct { Data struct {
Buckets map[string]string Buckets map[string]string

View file

@ -230,7 +230,7 @@ func RunServer() {
log.Fatal(err) log.Fatal(err)
} }
groupV1.GET("/bucket", v1Handler.HandleV1BucketList) groupV1.GET("/bucket", v1Handler.V1BucketsGET)
groupV1.GET("/bucket/:bucket", v1Handler.HandleV1BucketRead) groupV1.GET("/bucket/:bucket", v1Handler.HandleV1BucketRead)

View file

@ -53,18 +53,18 @@ func HandleVieEtudianteOrganisme(c echo.Context) error {
func (h *WebHandler) HandleDocumentation(c echo.Context) error { func (h *WebHandler) HandleDocumentation(c echo.Context) error {
var response webresponse.HandleDocumentationResponse var response webresponse.HandleDocumentationResponse
v1BucketListResponse, err := h.ApiClient.ListBuckets() v1BucketsGET, err := h.ApiClient.ListBuckets()
if err != nil { if err != nil {
response.Error = err.Error() response.Error = err.Error()
response.Message = v1BucketListResponse.Message response.Message = v1BucketsGET.Message
response.StatusCode = v1BucketListResponse.StatusCode response.StatusCode = v1BucketsGET.StatusCode
return c.Render(response.StatusCode, "documentation-html", response) return c.Render(response.StatusCode, "documentation-html", response)
} }
//TODO check v1BucketListRespone StatusCode and Error //TODO check v1BucketsGET StatusCode and Error
for bucket, displayName := range v1BucketListResponse.Data.Buckets { for bucket, displayName := range v1BucketsGET.Data.Buckets {
// TODO move call to dedicated API client method // TODO move call to dedicated API client method
var v1BucketReadResponse apiresponse.V1BucketRead var v1BucketReadResponse apiresponse.V1BucketRead
@ -134,16 +134,16 @@ func HandleAdmin(c echo.Context) error {
func (h *WebHandler) HandleAdminDocumentsUpload(c echo.Context) error { func (h *WebHandler) HandleAdminDocumentsUpload(c echo.Context) error {
var response webresponse.HandleAdminDocumentsUploadResponse var response webresponse.HandleAdminDocumentsUploadResponse
v1BucketListResponse, err := h.ApiClient.ListBuckets() v1BucketsGET, err := h.ApiClient.ListBuckets()
if err != nil { if err != nil {
response.StatusCode = v1BucketListResponse.StatusCode response.StatusCode = v1BucketsGET.StatusCode
response.Error = err.Error() response.Error = err.Error()
response.Message = v1BucketListResponse.Message response.Message = v1BucketsGET.Message
return c.Render(response.StatusCode, "admin-upload-html", nil) return c.Render(response.StatusCode, "admin-upload-html", nil)
} }
for bucketName, displayName := range v1BucketListResponse.Data.Buckets { for bucketName, displayName := range v1BucketsGET.Data.Buckets {
response.Data.Buckets = append(response.Data.Buckets, models.Bucket{ response.Data.Buckets = append(response.Data.Buckets, models.Bucket{
Name: bucketName, Name: bucketName,
DisplayName: displayName, DisplayName: displayName,
@ -157,16 +157,16 @@ func (h *WebHandler) HandleAdminDocumentsUpload(c echo.Context) error {
func (h *WebHandler) HandleAdminDocumentsUploadPOST(c echo.Context) error { func (h *WebHandler) HandleAdminDocumentsUploadPOST(c echo.Context) error {
var response webresponse.HandleAdminDocumentsUploadResponse var response webresponse.HandleAdminDocumentsUploadResponse
v1BucketListResponse, err := h.ApiClient.ListBuckets() v1BucketsGET, err := h.ApiClient.ListBuckets()
if err != nil { if err != nil {
response.StatusCode = v1BucketListResponse.StatusCode response.StatusCode = v1BucketsGET.StatusCode
response.Message = v1BucketListResponse.Message response.Message = v1BucketsGET.Message
response.Error = err.Error() response.Error = err.Error()
return c.Render(response.StatusCode, "admin-upload-html", response) return c.Render(response.StatusCode, "admin-upload-html", response)
} }
for bucketName, displayName := range v1BucketListResponse.Data.Buckets { for bucketName, displayName := range v1BucketsGET.Data.Buckets {
response.Data.Buckets = append(response.Data.Buckets, models.Bucket{ response.Data.Buckets = append(response.Data.Buckets, models.Bucket{
Name: bucketName, Name: bucketName,
DisplayName: displayName, DisplayName: displayName,