Documentation
¶
Index ¶
- Constants
- func CreateBuiltin() starlark.StringDict
- func FileServer(fsys *SourceFs) http.Handler
- func FormatName(filename, hash string) string
- func GetBoolAttr(s starlark.HasAttrs, key string) (bool, error)
- func GetIntAttr(s starlark.HasAttrs, key string) (int64, error)
- func GetListStringAttr(s starlark.HasAttrs, key string, optional bool) ([]string, error)
- func GetStringAttr(s starlark.HasAttrs, key string) (string, error)
- func GetStringList(list *starlark.List) ([]string, error)
- func LoadStoreInfo(fileName string, data []byte) (*utils.StoreInfo, error)
- func ParseName(filename string) (base, hash string)
- func ReadStoreInfo(fileName string, inp []byte) (*utils.StoreInfo, error)
- type AppConfig
- type DiskReadFS
- func (d *DiskReadFS) Glob(pattern string) (matches []string, err error)
- func (d *DiskReadFS) Open(name string) (fs.File, error)
- func (d *DiskReadFS) ReadFile(name string) ([]byte, error)
- func (d *DiskReadFS) Reset()
- func (d *DiskReadFS) Stat(name string) (fs.FileInfo, error)
- func (d *DiskReadFS) StaticFiles() []string
- type DiskWriteFS
- type HtmxConfig
- type RouteConfig
- type SourceFs
- func (f *SourceFs) ClearCache()
- func (f *SourceFs) Glob(pattern string) ([]string, error)
- func (f *SourceFs) HashName(name string) string
- func (f *SourceFs) Open(name string) (fs.File, error)
- func (f *SourceFs) ParseFS(funcMap template.FuncMap, patterns ...string) (*template.Template, error)
- func (f *SourceFs) ParseName(filename string) (base, hash string)
- func (f *SourceFs) Stat(name string) (fs.FileInfo, error)
- func (f *SourceFs) StaticFiles() []string
- type WorkFs
- type WritableSourceFs
Constants ¶
const ( DEFAULT_MODULE = "ace" DOC_MODULE = "doc" TABLE_MODULE = "table" APP = "app" PAGE = "page" FRAGMENT = "fragment" STYLE = "style" REDIRECT = "redirect" PERMISSION = "permission" RESPONSE = "response" LIBRARY = "library" DEFAULT_REDIRECT_CODE = 303 )
const ( // Constants included in the ace builtin module GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" HTML = "HTML" JSON = "JSON" TEXT = "TEXT" )
const ( APP_FILE_NAME = "app.star" APP_CONFIG_KEY = "app" DEFAULT_HANDLER = "handler" ERROR_HANDLER = "error_handler" METHODS_DELIMITER = "," CONFIG_LOCK_FILE_NAME = "config_gen.lock" SCHEMA_FILE_NAME = "schema.star" 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" ACCOUNT_SEPERATOR = "#" )
const ( TYPE = "type" FIELD = "field" INDEX = "index" )
const COMPRESSION_TYPE = "br" // brotli uses br as the encoding type
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 GetListStringAttr ¶
func LoadStoreInfo ¶ added in v0.4.0
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 DiskReadFS ¶ added in v0.2.0
func NewDiskReadFS ¶ added in v0.2.0
func NewDiskReadFS(logger *utils.Logger, root string) *DiskReadFS
func (*DiskReadFS) Glob ¶ added in v0.2.0
func (d *DiskReadFS) Glob(pattern string) (matches []string, err error)
func (*DiskReadFS) ReadFile ¶ added in v0.2.0
func (d *DiskReadFS) ReadFile(name string) ([]byte, error)
func (*DiskReadFS) Reset ¶ added in v0.3.0
func (d *DiskReadFS) Reset()
func (*DiskReadFS) Stat ¶ added in v0.2.0
func (d *DiskReadFS) Stat(name string) (fs.FileInfo, error)
func (*DiskReadFS) StaticFiles ¶ added in v0.3.0
func (d *DiskReadFS) StaticFiles() []string
type DiskWriteFS ¶ added in v0.2.0
type DiskWriteFS struct {
*DiskReadFS
}
func (*DiskWriteFS) Remove ¶ added in v0.2.0
func (d *DiskWriteFS) Remove(name string) error
type HtmxConfig ¶
type HtmxConfig struct {
Version string `json:"version"`
}
type RouteConfig ¶
type SourceFs ¶ added in v0.2.0
type SourceFs struct { utils.ReadableFS Root string // contains filtered or unexported fields }
SourceFs is the implementation of source file system
func NewSourceFs ¶ added in v0.2.0
func (*SourceFs) ClearCache ¶ added in v0.2.0
func (f *SourceFs) ClearCache()
func (*SourceFs) HashName ¶ added in v0.2.0
HashName returns the hash name for a path, if exists. Otherwise returns the original path.
func (*SourceFs) Open ¶ added in v0.2.0
Open returns a reference to the named file. If name is a hash name then the underlying file is used.
func (*SourceFs) ParseName ¶ added in v0.2.0
ParseName splits formatted hash filename into its base & hash components.
func (*SourceFs) StaticFiles ¶ added in v0.3.0
type WorkFs ¶ added in v0.2.0
type WorkFs struct { utils.WritableFS Root string }
WorkFs is the implementation of work file system
type WritableSourceFs ¶ added in v0.2.0
type WritableSourceFs struct {
*SourceFs
}
func (*WritableSourceFs) Remove ¶ added in v0.2.0
func (w *WritableSourceFs) Remove(name string) error