resource

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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.

func (Resource) Name

func (Resource) Name() string

func (Resource) New

func (r Resource) New(name string) (schema.ResourceInstance, error)

func (Resource) Schema

func (Resource) Schema() []schema.Attribute

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.

func (*ResourceInstance) Validate

func (r *ResourceInstance) Validate(ctx context.Context, state schema.State, resolve schema.Resolver) (any, error)

Validate decodes the incoming state, resolves references, and returns the validated *Resource configuration for use by Plan and Apply.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL