Documentation
¶
Index ¶
- Constants
- func CreateBuiltin() starlark.StringDict
- func FileServer(fsys *AppFS) http.Handler
- func FormatName(filename, hash string) string
- func GetBoolAttr(s *starlarkstruct.Struct, key string) (bool, error)
- func GetIntAttr(s *starlarkstruct.Struct, key string) (int64, error)
- func GetListStringAttr(s *starlarkstruct.Struct, key string, optional bool) ([]string, error)
- func GetStringAttr(s *starlarkstruct.Struct, key string) (string, error)
- func ParseName(filename string) (base, hash string)
- type AppConfig
- type AppFS
- func (f *AppFS) ClearCache()
- func (f *AppFS) Glob(pattern string) ([]string, error)
- func (f *AppFS) HashName(name string) string
- func (f *AppFS) Open(name string) (fs.File, error)
- func (f *AppFS) ParseFS(funcMap template.FuncMap, patterns ...string) (*template.Template, error)
- func (f *AppFS) ParseName(filename string) (base, hash string)
- func (f *AppFS) ReadFile(name string) ([]byte, error)
- func (f *AppFS) Remove(name string) error
- func (f *AppFS) Stat(name string) (fs.FileInfo, error)
- func (f *AppFS) Write(name string, bytes []byte) error
- type HtmxConfig
- type RouteConfig
- type WritableFS
Constants ¶
const ( DEFAULT_MODULE = "ace" APP = "app" PAGE = "page" FRAGMENT = "fragment" STYLE = "style" REDIRECT = "redirect" PERMISSION = "permission" RESPONSE = "response" LIBRARY = "library" DEFAULT_REDIRECT_CODE = 303 )
const ( APP_FILE_NAME = "app.star" APP_CONFIG_KEY = "app" DEFAULT_HANDLER = "handler" METHODS_DELIMITER = "," CONFIG_LOCK_FILE_NAME = "config_gen.lock" BUILTIN_PLUGIN_SUFFIX = "in" STARLARK_FILE_SUFFIX = ".star" INDEX_FILE = "index.go.html" INDEX_GEN_FILE = "index_gen.go.html" CLACE_GEN_FILE = "clace_gen.go.html" )
Variables ¶
This section is empty.
Functions ¶
func CreateBuiltin ¶
func CreateBuiltin() starlark.StringDict
func FileServer ¶
FileServer returns an http.Handler for serving FS files. It provides a simplified implementation of http.FileServer which is used to aggressively cache files on the client since the file hash is in the filename.
Because FileServer is focused on small known path files, several features of http.FileServer have been removed including canonicalizing directories, defaulting index.html pages, precondition checks, & content range headers.
func FormatName ¶
FormatName returns a hash name that inserts hash before the filename's extension. If no extension exists on filename then the hash is appended. Returns blank string the original filename if hash is blank. Returns a blank string if the filename is blank.
func GetBoolAttr ¶
func GetBoolAttr(s *starlarkstruct.Struct, key string) (bool, error)
func GetIntAttr ¶
func GetIntAttr(s *starlarkstruct.Struct, key string) (int64, error)
func GetListStringAttr ¶
func GetStringAttr ¶
func GetStringAttr(s *starlarkstruct.Struct, key string) (string, error)
Types ¶
type AppConfig ¶
type AppConfig struct { Routing RouteConfig `json:"routing"` Htmx HtmxConfig `json:"htmx"` }
func NewAppConfig ¶
func NewAppConfig() *AppConfig
NewAppConfig creates an AppConfig with default values. This config is used when lock file is not present. The config file load order is
DefaultAppConfig -> StarlarkAppConfig
func NewCompatibleAppConfig ¶
func NewCompatibleAppConfig() *AppConfig
NewCompatibleAppConfig creates an AppConfig focused on maintaining backward compatibility. This is used when the app is created from a source url where the source has the config lock file present. The configs are read in the order
CompatibleAppConfig -> LockFile -> StarlarkAppConfig
The goal is that if the application has a lock file, then all settings will attempt to be locked such that there should not be any change in behavior when the Clace version is updated. Removing the lock file will result in new config defaults getting applied, which can be done when the app developer wants to do an application refresh. Refresh will require additional testing to ensure that UI functionality is not changed..
type AppFS ¶
type AppFS struct { Root string // contains filtered or unexported fields }
AppFS is the implementation of app file system
func (*AppFS) ClearCache ¶
func (f *AppFS) ClearCache()
func (*AppFS) HashName ¶
HashName returns the hash name for a path, if exists. Otherwise returns the original path.
func (*AppFS) Open ¶
Open returns a reference to the named file. If name is a hash name then the underlying file is used.
type HtmxConfig ¶
type HtmxConfig struct {
Version string `json:"version"`
}