Documentation
¶
Index ¶
- type Resource
- type ResourceInstance
- func (r *ResourceInstance) Apply(ctx context.Context, v any) error
- func (r *ResourceInstance) HandlerFS() fs.FS
- func (r *ResourceInstance) HandlerPath() string
- func (r *ResourceInstance) OnStateChange(source schema.ResourceInstance)
- func (r *ResourceInstance) OnStateRemove(source schema.ResourceInstance)
- func (r *ResourceInstance) Read(ctx context.Context) (schema.State, error)
- func (r *ResourceInstance) Spec() *openapi.PathItem
- func (r *ResourceInstance) Validate(ctx context.Context, state schema.State, resolve schema.Resolver) (any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resource ¶
type Resource struct {
Path string `name:"path" required:"" help:"URL path relative to the router prefix"`
Dir string `name:"dir" required:"" help:"Directory on disk to serve"`
Summary string `name:"summary" default:"" help:"Short summary for the OpenAPI spec"`
Description string `name:"description" default:"" help:"Description for the OpenAPI spec"`
Endpoints []string `name:"endpoints" readonly:"" help:"Full URL endpoints for this handler"`
}
Resource describes a static file server resource type. The Dir field specifies the directory on disk to serve. The Path field determines the URL path relative to the router prefix. Summary and Description are surfaced via the OpenAPI specification.
type ResourceInstance ¶
type ResourceInstance struct {
provider.ResourceInstance[Resource]
// contains filtered or unexported fields
}
ResourceInstance is a live instance of a static file server resource.
func (*ResourceInstance) Apply ¶
func (r *ResourceInstance) Apply(ctx context.Context, v any) error
Apply materialises the resource using the validated configuration. It creates an httpstatic.Static backed by os.DirFS for the configured directory.
func (*ResourceInstance) HandlerFS ¶
func (r *ResourceInstance) HandlerFS() fs.FS
HandlerFS returns the filesystem to serve.
func (*ResourceInstance) HandlerPath ¶
func (r *ResourceInstance) HandlerPath() string
HandlerPath returns the route path relative to the router prefix.
func (*ResourceInstance) OnStateChange ¶
func (r *ResourceInstance) OnStateChange(source schema.ResourceInstance)
OnStateChange is called by the observer system when an instance that references this handler has its state changed. If the source is an httprouter, the reference is stored so [Read] can compute the endpoints dynamically.
func (*ResourceInstance) OnStateRemove ¶
func (r *ResourceInstance) OnStateRemove(source schema.ResourceInstance)
OnStateRemove is called by the observer system when an instance that references this handler is being destroyed. If the source is an httprouter, its reference is removed.
func (*ResourceInstance) Read ¶
Read returns the live state of the handler, computing the endpoints dynamically from all attached routers' current state.
func (*ResourceInstance) Spec ¶
func (r *ResourceInstance) Spec() *openapi.PathItem
HandlerSpec returns the OpenAPI path-item for this handler, or nil.