Documentation
¶
Index ¶
Constants ¶
const ( // FileScheme represents the "file" scheme. FileScheme = "file" // HttpScheme represents the "http" scheme. HttpScheme = "http" // HttpsScheme represents the "https" scheme. HttpsScheme = "https" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultResourceResolver ¶
type DefaultResourceResolver struct {
}
DefaultResourceResolver is the default implementation of the ResourceResolver interface.
func NewDefaultResourceResolver ¶
func NewDefaultResourceResolver() *DefaultResourceResolver
NewDefaultResourceResolver creates a new instance of DefaultResourceResolver.
type FileResource ¶
type FileResource struct {
// contains filtered or unexported fields
}
FileResource struct represents a file-based resource.
func NewFileResource ¶
func NewFileResource(path string) *FileResource
NewFileResource function creates a new FileResource with the given file path.
func (*FileResource) Exists ¶
func (r *FileResource) Exists() bool
Exists method checks if the file resource exists.
func (*FileResource) File ¶
func (r *FileResource) File() (fs.File, error)
File method opens the file resource and returns a fs.File.
func (*FileResource) Location ¶
func (r *FileResource) Location() string
Location method returns the location of the file resource.
func (*FileResource) Name ¶
func (r *FileResource) Name() string
Name method returns the name of the file resource.
func (*FileResource) Reader ¶
func (r *FileResource) Reader() (io.ReadCloser, error)
Reader method opens the file resource and returns an io.ReadCloser.
type Resource ¶
type Resource interface {
// Name method returns the name of the resource.
Name() string
// Location method returns the location of the resource.
Location() string
// Exists method checks if the resource exists.
Exists() bool
// Reader method returns an io.ReadCloser for the resource.
Reader() (io.ReadCloser, error)
}
Resource is an interface that represents a generic resource.
type ResourceResolver ¶
type ResourceResolver interface {
// Resolve method resolves a resource from the given location string.
Resolve(ctx context.Context, location string) (Resource, error)
}
ResourceResolver is an interface for resolving resources from location strings.
type URLResource ¶
type URLResource struct {
// contains filtered or unexported fields
}
URLResource struct represents a file-based resource.
func NewURLResource ¶
func NewURLResource(url *url.URL) *URLResource
NewURLResource function creates a new URLResource with the given URL.
func (*URLResource) Exists ¶
func (u *URLResource) Exists() bool
Exists method checks if the URL resource exists by making a HEAD request.
func (*URLResource) Location ¶
func (u *URLResource) Location() string
Location method returns the location of the URL resource.
func (*URLResource) Name ¶
func (u *URLResource) Name() string
Name method returns the name of the URL resource. It extracts the name from the URL path.
func (*URLResource) Reader ¶
func (u *URLResource) Reader() (io.ReadCloser, error)
Reader method makes a GET request to the URL and returns an io.ReadCloser.
func (*URLResource) URL ¶
func (u *URLResource) URL() *url.URL
URL method returns the underlying URL of the resource.