{"modulePath":"github.com/mutablelogic/go-server","version":"v1.6.18","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package resource\n\n## Types\n\n```go\ntype Resource struct {\n\tListen       string                  `name:\"listen\" help:\"Listen address (e.g. localhost:8080)\"`\n\tDescription  string                  `name:\"description\" help:\"Server description for OpenAPI spec\"`\n\tEndpoint     string                  `name:\"endpoint\" readonly:\"\" help:\"Base URL of the running server\"`\n\tRouter       schema.ResourceInstance `name:\"router\" type:\"httprouter\" required:\"\" help:\"HTTP router\"`\n\tReadTimeout  time.Duration           `name:\"read_timeout\" default:\"5m\" help:\"Read timeout\"`\n\tWriteTimeout time.Duration           `name:\"write_timeout\" default:\"5m\" help:\"Write timeout\"`\n\tIdleTimeout  time.Duration           `name:\"idle_timeout\" default:\"5m\" help:\"Idle timeout for keep-alive connections\"`\n\tTLS          struct {\n\t\tName   string `name:\"name\" help:\"TLS server name\"`\n\t\tVerify bool   `name:\"verify\" default:\"true\" help:\"Verify client certificates\"`\n\t\tCert   []byte `name:\"cert\" sensitive:\"\" help:\"TLS certificate PEM data\"`\n\t\tKey    []byte `name:\"key\" sensitive:\"\" help:\"TLS key PEM data\"`\n\t} `embed:\"\" prefix:\"tls.\"`\n}\n```\n\n```go\nfunc (Resource) Name() string\n```\n\n```go\nfunc (r Resource) New(name string) (schema.ResourceInstance, error)\n```\n\n```go\nfunc (Resource) Schema() []schema.Attribute\n```\n\n```go\ntype ResourceInstance struct {\n\tprovider.ResourceInstance[Resource]\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *ResourceInstance) Apply(ctx context.Context, v any) error\n```\nApply materialises the resource using the validated configuration.\n\n```go\nfunc (r *ResourceInstance) Destroy(_ context.Context) error\n```\nDestroy tears down the resource and releases its backing infrastructure. It returns an error if the resource cannot be cleanly removed.\n\n```go\nfunc (r *ResourceInstance) Plan(ctx context.Context, v any) (schema.Plan, error)\n```\nPlan computes the diff and performs pre-flight checks on changed fields: probing the listen address for availability and validating TLS certificates (PEM parsing, key-pair match, expiry).\n\n```go\nfunc (r *ResourceInstance) Read(ctx context.Context) (schema.State, error)\n```\nRead returns the current state of the server instance. If the background server has exited with an error, it is returned.\n\n```go\nfunc (r *ResourceInstance) RuntimeErr() error\n```\nRuntimeErr returns the error from the background server goroutine, or nil if the server is running normally.\n\n```go\nfunc (r *ResourceInstance) Spec() *openapi.Server\n```\nSpec returns the OpenAPI server entry for this instance, or nil if the server has not started yet.\n\n```go\nfunc (r *ResourceInstance) Validate(ctx context.Context, state schema.State, resolve schema.Resolver) (any, error)\n```\nValidate decodes the incoming state, resolves references, and returns the validated \\*Resource configuration for use by Plan and Apply.\n\n","path":"github.com/mutablelogic/go-server/pkg/httpserver/resource","name":"resource","synopsis":"","isRedistributable":true}
