vise/go/resource/fs.go

41 lines
738 B
Go
Raw Normal View History

2023-03-31 11:52:04 +02:00
package resource
import (
"context"
2023-04-01 11:58:02 +02:00
"fmt"
"io/ioutil"
"path"
"strings"
2023-03-31 11:52:04 +02:00
)
type FsResource struct {
2023-04-01 15:47:03 +02:00
Path string
2023-03-31 11:52:04 +02:00
ctx context.Context
}
func NewFsResource(path string, ctx context.Context) (FsResource) {
return FsResource{
2023-04-01 15:47:03 +02:00
Path: path,
2023-03-31 11:52:04 +02:00
ctx: ctx,
}
}
2023-04-01 11:58:02 +02:00
func(fs FsResource) GetTemplate(sym string) (string, error) {
2023-04-01 15:47:03 +02:00
fp := path.Join(fs.Path, sym)
2023-04-01 11:58:02 +02:00
r, err := ioutil.ReadFile(fp)
s := string(r)
return strings.TrimSpace(s), err
2023-03-31 11:52:04 +02:00
}
2023-04-01 11:58:02 +02:00
func(fs FsResource) RenderTemplate(sym string, values map[string]string) (string, error) {
2023-03-31 11:52:04 +02:00
return "", nil
}
2023-04-01 11:58:02 +02:00
func(fs FsResource) GetCode(sym string) ([]byte, error) {
return []byte{}, nil
}
func(fs FsResource) FuncFor(sym string) (EntryFunc, error) {
return nil, fmt.Errorf("not implemented")
}