resources

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProviderNotFound = errors.New("provider not found for the request")

Functions

func ProcessEmbeds

func ProcessEmbeds(s string, root string, log slog.Logger) string

ProcessEmbeds processes "localfilename" directive in the md file and replaces it with the contents of the specified local file.

func RemoveEndOfPostMarker

func RemoveEndOfPostMarker(s string) string

RemoveEndOfPostMarker removes all text after a standard --endofpost-- marker line.

func SplitPath

func SplitPath(path string) []string

SplitPath splits the path into path elements according to the separator.

Types

type FilesystemResource

type FilesystemResource struct {
	// contains filtered or unexported fields
}

FilesystemResource is a resource that returns data from a root dir in the filesystem.

func NewFilesystemResource

func NewFilesystemResource(root string, log slog.Logger) *FilesystemResource

func (*FilesystemResource) Fulfill

Fulfill is part of the Provider interface.

type HttpProvider

type HttpProvider struct {
	// contains filtered or unexported fields
}

HttpProvider is a resources provider that can fulfill requests to an upstream provider via HTTP.

func NewHttpProvider

func NewHttpProvider(baseURL string) *HttpProvider

NewHttpProvider creates a new provider that responds to requests by forwarding them to an upstream server via HTTP.

func (*HttpProvider) Fulfill

type Provider

type Provider interface {
	Fulfill(ctx context.Context, uid clientintf.UserID, request *rpc.RMFetchResource) (*rpc.RMFetchResourceReply, error)
}

Provider is the interface for subsystems that provide resources.

func ProviderFunc

func ProviderFunc(f func(ctx context.Context, uid clientintf.UserID, request *rpc.RMFetchResource) (*rpc.RMFetchResourceReply, error)) Provider

ProviderFunc wraps the passed function as a Provider.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router is a Provider that matches requests to sub-providers using specific rules.

func NewRouter

func NewRouter() *Router

NewRouter initializes a new, empty router.

func (*Router) BindExactPath

func (r *Router) BindExactPath(path []string, p Provider)

BindExactPath binds the passed provider to be called whenever a request has an exact path.

func (*Router) BindPrefixPath

func (r *Router) BindPrefixPath(prefixPath []string, p Provider)

BindPrefixPath binds the passed provider to be called whenever a request has a path with the passed prefix.

func (*Router) FindProvider

func (r *Router) FindProvider(req *rpc.RMFetchResource) Provider

FindProvider attempts to find a provider to match the request.

func (*Router) Fulfill

Fulfill attempts to find a sub-provider to match and fulfill the request.

type StaticResource

type StaticResource struct {
	Data []byte
	Meta map[string]string
}

StaticResource is a resource that always returns the same data.

func (*StaticResource) Fulfill

Fulfill is part of the Provider interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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