Documentation
¶
Index ¶
- Variables
- func BarryTemplateFuncs(env, cacheDir string) template.FuncMap
- func ExecuteAPIFileWithSubprocess(filePath string, req *http.Request, params map[string]string) ([]byte, error)
- func ExecuteServerFileWithSubprocess(filePath string, req *http.Request, params map[string]string) (map[string]interface{}, error)
- func GetCachedHTML(config Config, route, ext string) ([]byte, bool)
- func IsNotFoundError(err error) bool
- func LoadPluginAndCall(filePath string, req *http.Request, params map[string]string) (map[string]interface{}, error)
- func MinifyAsset(env, path string, cacheDir string) string
- func SaveCachedHTML(config Config, routeKey, ext string, data []byte) error
- type ApiRoute
- type Config
- type ExecContext
- type LiveReloader
- type LiveReloaderInterface
- type Route
- type Router
- type RuntimeContext
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidPlugin = errors.New("invalid plugin: missing HandleRequest")
View Source
var ErrNotFound = errors.New("barry: not found")
View Source
var ErrPluginNotFound = errors.New("plugin not found")
View Source
var ExecuteAPIFile = func(filePath string, req *http.Request, params map[string]string) ([]byte, error) { result, err := LoadPluginAndCallFunc(filePath, req, params) if err != nil && err != ErrPluginNotFound { return nil, err } if result != nil { return json.Marshal(result) } return ExecuteAPIFileWithSubprocessFunc(filePath, req, params) }
View Source
var ExecuteAPIFileWithSubprocessFunc = ExecuteAPIFileWithSubprocess
View Source
var ExecuteServerFile = func(filePath string, req *http.Request, params map[string]string) (map[string]interface{}, error) { result, err := LoadPluginAndCallFunc(filePath, req, params) if err != nil && err != ErrPluginNotFound { return nil, err } if result != nil { return result, nil } return ExecuteServerFileWithSubprocessFunc(filePath, req, params) }
View Source
var ExecuteServerFileWithSubprocessFunc = ExecuteServerFileWithSubprocess
View Source
var LoadConfig = func(path string) *Config { data, err := os.ReadFile(path) if err != nil { return &Config{ OutputDir: "./cache", CacheEnabled: false, DebugHeaders: false, DebugLogs: false, } } var cfg Config yaml.Unmarshal(data, &cfg) if cfg.OutputDir == "" { cfg.OutputDir = "./cache" } return &cfg }
View Source
var LoadPluginAndCallFunc = LoadPluginAndCall
View Source
var NewLiveReloader = func() LiveReloaderInterface { return &LiveReloader{ clients: make(map[*websocket.Conn]bool), upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true }, }, } }
View Source
var NewRouter = func(config Config, ctx RuntimeContext) http.Handler { r := &Router{ config: config, env: ctx.Env, onReload: ctx.OnReload, } var wg sync.WaitGroup wg.Add(3) go func() { defer wg.Done() r.loadRoutes() }() go func() { defer wg.Done() r.loadComponentFiles() }() go func() { defer wg.Done() r.loadApiRoutes() }() wg.Wait() if ctx.EnableWatch { go r.watchEverything() } return r }
View Source
var SaveCachedHTMLFunc = SaveCachedHTML
Functions ¶
func BarryTemplateFuncs ¶ added in v0.1.9
func ExecuteAPIFileWithSubprocess ¶ added in v0.5.0
func ExecuteServerFileWithSubprocess ¶ added in v0.5.0
func IsNotFoundError ¶ added in v0.1.11
func LoadPluginAndCall ¶ added in v0.5.0
func MinifyAsset ¶ added in v0.1.9
Types ¶
type ExecContext ¶
type LiveReloader ¶
type LiveReloader struct {
// contains filtered or unexported fields
}
func (*LiveReloader) BroadcastReload ¶
func (lr *LiveReloader) BroadcastReload()
func (*LiveReloader) Handler ¶
func (lr *LiveReloader) Handler(w http.ResponseWriter, r *http.Request)
type LiveReloaderInterface ¶ added in v0.3.2
type LiveReloaderInterface interface { BroadcastReload() Handler(http.ResponseWriter, *http.Request) }
type RuntimeContext ¶
Click to show internal directories.
Click to hide internal directories.