Skip to content

Commit

Permalink
Add default AppProvider from the configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Sep 24, 2021
1 parent 94e8796 commit cf905da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/app/registry/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type mimeTypeConfig struct {
Name string `mapstructure:"name"`
Description string `mapstructure:"description"`
Icon string `mapstructure:"icon"`
DefaultApp string `mapstructure:"default_app"`
}

type config struct {
Expand Down Expand Up @@ -100,7 +101,12 @@ func New(m map[string]interface{}) (app.Registry, error) {
if ok {
newReg.mimetypes[m].apps = append(newReg.mimetypes[m].apps, addr)
} else {
newReg.mimetypes[m] = &mimeTypeIndex{apps: []string{addr}}
// set a default app provider if provided
mime, in := c.MimeTypes[m]
if !in {
return nil, errtypes.NotFound(fmt.Sprintf("mimetype %s not found in the configuration", m))
}
newReg.mimetypes[m] = &mimeTypeIndex{apps: []string{addr}, defaultApp: mime.DefaultApp}
}
}
}
Expand Down

0 comments on commit cf905da

Please sign in to comment.