Documentation ¶
Index ¶
- Variables
- func ReadLocation(location Location) ([]byte, error)
- type AppFile
- type AppFileView
- type DescriptedPath
- type Descriptor
- type EffectiveFile
- type EffectiveFileView
- type EffectiveResource
- type EffectiveResourceView
- type File
- type Fs
- type FsLevel
- type LeveledAferoFs
- type Location
- type Manager
- type Match
- type NewlineJoinedDescriptor
- func (d NewlineJoinedDescriptor) FindResources(fs Fs) ([]Location, error)
- func (d NewlineJoinedDescriptor) MatchResource(path string) (*Match, bool)
- func (d NewlineJoinedDescriptor) UpdateResource(_ context.Context, _ []ResourceFile, resource *ResourceFile, data []byte) (*ResourceFile, error)
- func (d NewlineJoinedDescriptor) ViewResources(resources []ResourceFile, rawView View) (interface{}, error)
- type Registry
- type ResourceFile
- type SimpleDescriptor
- func (d SimpleDescriptor) FindResources(fs Fs) ([]Location, error)
- func (d SimpleDescriptor) MatchResource(path string) (*Match, bool)
- func (d SimpleDescriptor) UpdateResource(_ context.Context, _ []ResourceFile, resource *ResourceFile, data []byte) (*ResourceFile, error)
- func (d SimpleDescriptor) ViewResources(resources []ResourceFile, rawView View) (interface{}, error)
- type SizeLimitDescriptor
- type ValidateResource
- type ValidateResourceView
- type View
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = &Registry{}
var ErrResourceNotFound = apierrors.NotFound.WithReason("ResourceNotFound").
New("specified resource is not configured")
Functions ¶
func ReadLocation ¶
Types ¶
type AppFileView ¶
AppFileView is an view on the resources at specific path in the App FS. Since the path is specific, so the view is single-locale.
type DescriptedPath ¶
type DescriptedPath struct { Descriptor Descriptor Path string }
type Descriptor ¶
type Descriptor interface { MatchResource(path string) (*Match, bool) FindResources(fs Fs) ([]Location, error) ViewResources(resources []ResourceFile, view View) (interface{}, error) UpdateResource(ctx context.Context, resourcesInAllFss []ResourceFile, resourceInTargetFs *ResourceFile, data []byte) (*ResourceFile, error) }
func RegisterResource ¶
func RegisterResource(desc Descriptor) Descriptor
type EffectiveFile ¶
type EffectiveFile struct {
Path string
}
func (EffectiveFile) EffectiveFilePath ¶
func (v EffectiveFile) EffectiveFilePath() string
type EffectiveFileView ¶
EffectiveFileView is an view on the resources at specific path in all FSs. Since the path is specific, so the view is single-locale.
type EffectiveResource ¶
func (EffectiveResource) DefaultLanguageTag ¶
func (v EffectiveResource) DefaultLanguageTag() string
func (EffectiveResource) PreferredLanguageTags ¶
func (v EffectiveResource) PreferredLanguageTags() []string
func (EffectiveResource) SupportedLanguageTags ¶
func (v EffectiveResource) SupportedLanguageTags() []string
type EffectiveResourceView ¶
type EffectiveResourceView interface { View SupportedLanguageTags() []string DefaultLanguageTag() string PreferredLanguageTags() []string }
EffectiveResourceView is an view on the resources in all FSs. Since there is no path, the view is locale-resolved.
type LeveledAferoFs ¶
func (LeveledAferoFs) GetFsLevel ¶
func (f LeveledAferoFs) GetFsLevel() FsLevel
type Location ¶
func EnumerateAllLocations ¶
type NewlineJoinedDescriptor ¶
func (NewlineJoinedDescriptor) FindResources ¶
func (d NewlineJoinedDescriptor) FindResources(fs Fs) ([]Location, error)
func (NewlineJoinedDescriptor) MatchResource ¶
func (d NewlineJoinedDescriptor) MatchResource(path string) (*Match, bool)
func (NewlineJoinedDescriptor) UpdateResource ¶
func (d NewlineJoinedDescriptor) UpdateResource(_ context.Context, _ []ResourceFile, resource *ResourceFile, data []byte) (*ResourceFile, error)
func (NewlineJoinedDescriptor) ViewResources ¶
func (d NewlineJoinedDescriptor) ViewResources(resources []ResourceFile, rawView View) (interface{}, error)
type Registry ¶
type Registry struct {
Descriptors []Descriptor
}
func (*Registry) Register ¶
func (r *Registry) Register(desc Descriptor) Descriptor
type SimpleDescriptor ¶
type SimpleDescriptor struct {
Path string
}
SimpleDescriptor does not support view.
func (SimpleDescriptor) FindResources ¶
func (d SimpleDescriptor) FindResources(fs Fs) ([]Location, error)
func (SimpleDescriptor) MatchResource ¶
func (d SimpleDescriptor) MatchResource(path string) (*Match, bool)
func (SimpleDescriptor) UpdateResource ¶
func (d SimpleDescriptor) UpdateResource(_ context.Context, _ []ResourceFile, resource *ResourceFile, data []byte) (*ResourceFile, error)
func (SimpleDescriptor) ViewResources ¶
func (d SimpleDescriptor) ViewResources(resources []ResourceFile, rawView View) (interface{}, error)
type SizeLimitDescriptor ¶
type SizeLimitDescriptor interface { Descriptor GetSizeLimit() int // Size limit in bytes }
type ValidateResource ¶
type ValidateResource struct{}
type ValidateResourceView ¶
type ValidateResourceView interface { View // contains filtered or unexported methods }
ValidateResourceView validates the resource itself.
type View ¶
type View interface {
// contains filtered or unexported methods
}
View is an specific view on the resources described by an Descriptor.
Views are defined within this package only, while descriptor is meant to be defined outside this package. Therefore, when a new descriptor is being introduced, the author has to think about what views the descriptor supports.
Most descriptors only support a subset of all defined views.
Some resources has language tag in their path.
View |- AppFileView |- EffectiveFileView |- EffectiveResourceView |- ValidateResourceView