Documentation
¶
Index ¶
- Variables
- func ProcessEmbeds(s string, root string, log slog.Logger) string
- func RemoveEndOfPostMarker(s string) string
- func SplitPath(path string) []string
- type FilesystemResource
- type HttpProvider
- type Provider
- type Router
- func (r *Router) BindExactPath(path []string, p Provider)
- func (r *Router) BindPrefixPath(prefixPath []string, p Provider)
- func (r *Router) FindProvider(req *rpc.RMFetchResource) Provider
- func (r *Router) Fulfill(ctx context.Context, uid clientintf.UserID, req *rpc.RMFetchResource) (*rpc.RMFetchResourceReply, error)
- type StaticResource
Constants ¶
This section is empty.
Variables ¶
var ErrProviderNotFound = errors.New("provider not found for the request")
Functions ¶
func ProcessEmbeds ¶
ProcessEmbeds processes "localfilename" directive in the md file and replaces it with the contents of the specified local file.
func RemoveEndOfPostMarker ¶
RemoveEndOfPostMarker removes all text after a standard --endofpost-- marker line.
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 ¶
func (fr *FilesystemResource) Fulfill(ctx context.Context, uid clientintf.UserID, req *rpc.RMFetchResource) (*rpc.RMFetchResourceReply, error)
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 ¶
func (h *HttpProvider) Fulfill(ctx context.Context, uid clientintf.UserID, request *rpc.RMFetchResource) (*rpc.RMFetchResourceReply, error)
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 (*Router) BindExactPath ¶
BindExactPath binds the passed provider to be called whenever a request has an exact path.
func (*Router) BindPrefixPath ¶
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 ¶
func (r *Router) Fulfill(ctx context.Context, uid clientintf.UserID, req *rpc.RMFetchResource) (*rpc.RMFetchResourceReply, error)
Fulfill attempts to find a sub-provider to match and fulfill the request.
type StaticResource ¶
StaticResource is a resource that always returns the same data.
func (*StaticResource) Fulfill ¶
func (sr *StaticResource) Fulfill(ctx context.Context, uid clientintf.UserID, req *rpc.RMFetchResource) (*rpc.RMFetchResourceReply, error)
Fulfill is part of the Provider interface.