Improve API

This commit is contained in:
2023-04-02 17:31:37 +03:00
parent bc61b916f9
commit 11a6171954
12 changed files with 260 additions and 25 deletions

View File

@@ -1,6 +1,8 @@
package rest
import (
"fmt"
"github.com/derfenix/webarchive/api/openapi"
"github.com/derfenix/webarchive/entity"
)
@@ -93,7 +95,7 @@ func StatusToRest(s entity.Status) openapi.Status {
}
}
func FormatFromRest(format []openapi.Format) []entity.Format {
func FormatFromRest(format []openapi.Format) ([]entity.Format, error) {
var formats []entity.Format
switch {
@@ -112,11 +114,14 @@ func FormatFromRest(format []openapi.Format) []entity.Format {
case openapi.FormatSingleFile:
formats[i] = entity.FormatSingleFile
default:
return nil, fmt.Errorf("invalid format value %s", format)
}
}
}
return formats
return formats, nil
}
func FormatToRest(format entity.Format) openapi.Format {