[BREAKING] Change Config.Server.Documents type
[]string -> map[string]string Add DisplayName object to use in documentation-html render
This commit is contained in:
parent
6165a90d18
commit
789af54121
3 changed files with 25 additions and 16 deletions
|
@ -96,7 +96,12 @@ func init() {
|
|||
viper.BindPFlag("server.documents.use_ssl", serverCmd.Flags().Lookup("server-documents-use-ssl"))
|
||||
|
||||
// server.documents.buckets - --server-documents-buckets
|
||||
serverCmd.Flags().StringSlice("server-documents-buckets", []string{"proces-verbaux", "politiques-et-reglements"}, "Buckets that are allowed to be accessed by the API (config: server.documents.buckets)")
|
||||
serverCmd.Flags().StringToString("server-documents-buckets", map[string]string{
|
||||
"proces-verbaux": "Procès-verbaux",
|
||||
"politiques": "Politiques",
|
||||
"reglements": "Règlements",
|
||||
"formulaires": "Formulaires",
|
||||
}, "Buckets that are allowed to be accessed by the API (config: server.documents.buckets)")
|
||||
viper.BindPFlag("server.documents.buckets", serverCmd.Flags().Lookup("server-documents-buckets"))
|
||||
|
||||
// server.api.auth - --server-api-auth
|
||||
|
@ -293,7 +298,7 @@ func handleDocumentation(c echo.Context) error {
|
|||
return c.Render(http.StatusInternalServerError, "documentation-html", nil)
|
||||
}
|
||||
|
||||
var buckets []string
|
||||
var buckets map[string]string
|
||||
|
||||
err = json.Unmarshal(result, &buckets)
|
||||
if err != nil {
|
||||
|
@ -301,13 +306,14 @@ func handleDocumentation(c echo.Context) error {
|
|||
}
|
||||
|
||||
type Bucket struct {
|
||||
Name string
|
||||
Documents []string
|
||||
Name string
|
||||
DisplayName string
|
||||
Documents []string
|
||||
}
|
||||
|
||||
var data []Bucket
|
||||
|
||||
for _, bucket := range buckets {
|
||||
for bucket, displayName := range buckets {
|
||||
content, err := client.Call(http.MethodGet, fmt.Sprintf("/v1/bucket/%s", bucket))
|
||||
if err != nil {
|
||||
return c.Render(http.StatusInternalServerError, "documentation-html", nil)
|
||||
|
@ -339,8 +345,9 @@ func handleDocumentation(c echo.Context) error {
|
|||
*/
|
||||
|
||||
data = append(data, Bucket{
|
||||
Name: bucket,
|
||||
Documents: documents,
|
||||
Name: bucket,
|
||||
DisplayName: displayName,
|
||||
Documents: documents,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ type Config struct {
|
|||
Protocol string `mapstructure:"protocol"`
|
||||
} `mapstructure:"api"`
|
||||
Documents struct {
|
||||
AccessKeyId string `mapstructure:"access_key_id"`
|
||||
Buckets []string `mapstructure:"buckets"`
|
||||
Endpoint string `mapstructure:"endpoint"`
|
||||
SecretAccessKey string `mapstructure:"secret_access_key"`
|
||||
UseSSL bool `mapstructure:"use_ssl"`
|
||||
KeyId string `mapstructure:"keyid"`
|
||||
KeyValue string `mapstructure:"keyvalue"`
|
||||
AccessKeyId string `mapstructure:"access_key_id"`
|
||||
Buckets map[string]string `mapstructure:"buckets"`
|
||||
Endpoint string `mapstructure:"endpoint"`
|
||||
SecretAccessKey string `mapstructure:"secret_access_key"`
|
||||
UseSSL bool `mapstructure:"use_ssl"`
|
||||
KeyId string `mapstructure:"keyid"`
|
||||
KeyValue string `mapstructure:"keyvalue"`
|
||||
} `mapstructure:"documents"`
|
||||
Port int `mapstructure:"port"`
|
||||
} `mapstructure:"server"`
|
||||
|
|
|
@ -35,8 +35,10 @@ server:
|
|||
#
|
||||
# Also used to specify which buckets are to be created on receiving a POST request on /v1/seed
|
||||
buckets:
|
||||
- 'proces-verbaux'
|
||||
- 'politiques-et-reglements'
|
||||
'proces-verbaux': 'Procès-verbaux'
|
||||
'politiques': 'Politiques'
|
||||
'reglements': 'Règlements'
|
||||
'formulaires': 'Formulaires'
|
||||
|
||||
api:
|
||||
# Enable or disable key auth on /v1 routes
|
||||
|
|
Loading…
Reference in a new issue