Documentation ¶
Index ¶
- Variables
- func CheckETag(www http.ResponseWriter, req *http.Request, modtime time.Time) (rangeReq string, done bool)
- func CheckLastModified(www http.ResponseWriter, req *http.Request, modtime time.Time) bool
- func ConvMakrdown(in, out string) (err error)
- func ExecuteCommands(CommandToRun string, inputFile, outputFile, inExt, outExt string) (ok bool, outString string, errString string)
- func ExecuteCommandsMulti(CommandToRun string, inputFile []string, outputFile string, inExt []string, ...) (ok bool, outString string, errString string)
- func GenLockKey(s0 string, s ...string) (rv string)
- func GetRwHdlrFromWWW_2(www http.ResponseWriter, req *http.Request) (rw *goftlmux.MidBuffer, ok bool)
- func InitNLogged()
- func LockCmd(aKey string)
- func LogErrors(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, s string)
- func LogOutputAsSuccess(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, s string)
- func OutputErrors(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, s string)
- func RmExt(filename string) string
- func RmExtSpecified(filename, extension string) string
- func ServeFile(w http.ResponseWriter, r *http.Request, name string)
- func UnLockCmd(aKey string)
- type ACommandToRun
- type Dir
- type ExLockType
- type ExtProcessType
- type FSConfig
- type File
- type FileServerType
- func (hdlr *FileServerType) InitializeWithConfigData(next http.Handler, gCfg *cfg.ServerGlobalConfigType, serverName string, ...) (err error)
- func (hdlr *FileServerType) PreValidate(gCfg *cfg.ServerGlobalConfigType, cfgData map[string]interface{}, ...) (err error)
- func (fcfg *FileServerType) ServeFile(www http.ResponseWriter, req *http.Request, name string)
- func (fcfg *FileServerType) ServeHTTP(www http.ResponseWriter, req *http.Request)
- type FileSystem
- type InternalFuncTableType
- type InternalFuncType
- type PreRuleType
- type RebuildFlag
- type RuleStatus
- func ResolveFnThemeUser(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, urlIn string, ...) (urlOut string, rootOut string, stat RuleStatus, err error)
- func UrlFileExt(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, urlIn string, ...) (urlOut string, rootOut string, stat RuleStatus, err error)
- type UrlModifyFunc
Constants ¶
This section is empty.
Variables ¶
var CommandLocationMap map[string]string // xyzzyInit - Command set map of commands to full paths
var ErrInputFileMissing = errors.New("Unable to find file that was avaialbe earlier in processing.")
var ErrOutputFileError = errors.New("Output error")
var ExtProcessTable []*ExtProcessType
var InternalFuncLookup map[string]InternalFuncTableType // xyzzyInit - Lookup of functions for ExtProcessType table
Functions ¶
func CheckETag ¶
func CheckETag(www http.ResponseWriter, req *http.Request, modtime time.Time) (rangeReq string, done bool)
============================================================================================================================================ CheckETag implements If-None-Match and If-Range checks.
The ETag or modtime must have been previously set in the http.ResponseWriter's headers. The modtime is only compared at second granularity and may be the zero value to mean unknown.
The return value is the effective request "Range" header to use and whether this request is now considered done.
func CheckLastModified ¶
============================================================================================================================================ modtime is the modification time of the resource to be served, or IsZero(). return value is whether this request is now complete.
func ConvMakrdown ¶
func ExecuteCommands ¶
func ExecuteCommands(CommandToRun string, inputFile, outputFile, inExt, outExt string) (ok bool, outString string, errString string)
ok, errString := ExecuteCommands(tr.CommandToRun) need to make this a "worker" and only run 1 at a time of this.,, All others wait pending!
func ExecuteCommandsMulti ¶
func GenLockKey ¶
func GetRwHdlrFromWWW_2 ¶
func GetRwHdlrFromWWW_2(www http.ResponseWriter, req *http.Request) (rw *goftlmux.MidBuffer, ok bool)
============================================================================================================================================
func InitNLogged ¶
func InitNLogged()
func LogErrors ¶
func LogErrors(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, s string)
func LogOutputAsSuccess ¶
func LogOutputAsSuccess(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, s string)
func OutputErrors ¶
func OutputErrors(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, s string)
func RmExtSpecified ¶
Remove the specified extension from the file name. If the extension is the entire file name then return an empty stirng.
Types ¶
type ACommandToRun ¶
type ExLockType ¶
type ExLockType struct {
// contains filtered or unexported fields
}
type ExtProcessType ¶
type ExtProcessType struct { ToExt []string `json:"ToExt"` // Set of output extensions FromExt string `json:"FromExt"` // Input extension HasFs string `json:"HasFs"` // File sep CommandToRun string `json:"CommandToRun"` // typescript {{.f_base}}.ts ReRun bool `json:"ReRun"` // if false(default) then check timestamps on input->output, else just run every time -- xyzzy not implemented yet? InternalFunc InternalFuncType `json:"-"` // if true then if InternalFunc != nil, then call it. InternalFuncName string `json:"InternalFunc"` // string name to lookkup InteralFunc by }
type FSConfig ¶
type FSConfig struct { Name string IndexPage []string // list of paths for IndexPage MayShowDirectoryListing bool // ----------------------------------------------------------------------------------------------------------- PreMangle bool // Process ULR before - this is like strip prefix PreRule []PreRuleType }
Pre-Rules Post-Rules Data-Avail-Rules
func NewFSConfig ¶
func (*FSConfig) AddPreRule ¶
func (g *FSConfig) AddPreRule(r []PreRuleType) *FSConfig
func (*FSConfig) DirectoryListings ¶
type File ¶
type File interface { io.Closer io.Reader Readdir(count int) ([]os.FileInfo, error) Seek(offset int64, whence int) (int64, error) Stat() (os.FileInfo, error) }
A File is returned by a FileSystem's Open method and can be served by the FileServer implementation.
The methods should behave the same as those on an *os.File.
type FileServerType ¶
type FileServerType struct { Next http.Handler // No Next, this is the bottom of the stack. Paths []string Root []string StripPrefix string IndexFileList []string ThemeRoot string ThemeCookieName string UserCookieName string LineNo int Cfg *FSConfig // Runtime configuration for servring and finding files. SampleNumber int // xyzzy - not implemented yet SamplePattern string // xyzzy - not implemented yet CommandLocationMap map[string]string // xyzzyInit - Command set map of commands to full paths ExtProcessTable []*ExtProcessType }
func NewFileServer ¶
func (*FileServerType) InitializeWithConfigData ¶
func (hdlr *FileServerType) InitializeWithConfigData(next http.Handler, gCfg *cfg.ServerGlobalConfigType, serverName string, pNo, callNo int) (err error)
func (*FileServerType) PreValidate ¶
func (hdlr *FileServerType) PreValidate(gCfg *cfg.ServerGlobalConfigType, cfgData map[string]interface{}, serverName string, pNo, callNo int) (err error)
func (*FileServerType) ServeFile ¶
func (fcfg *FileServerType) ServeFile(www http.ResponseWriter, req *http.Request, name string)
============================================================================================================================================
1. Transform extensions
.md->.html .sccs->.css .ts->.js f: [ .ext ], t [ .out, .other ] If request .other, and have .ext then run command and build If request .ext and have .other, then if out of date rebuild
[
{ "f": ".js", "t": [ ".min.js", ".min.map" ], "cmd": "uglifyjs --input {{.f}} --output {{.t}} --generate-mapfile" }
, { "f": ".ts", "t": [ ".js" ], "cmd": "typescirpt {{.f}} " } , { "f": ".css", "t": [ ".min.css" ], "cmd": "pack-css --in {{.f}} --out {{.t}}" } ]
name is '/'-separated, not filepath.Separator. fs contains the directory name, name is the file name.
func (*FileServerType) ServeHTTP ¶
func (fcfg *FileServerType) ServeHTTP(www http.ResponseWriter, req *http.Request)
type FileSystem ¶
A FileSystem implements access to a collection of named files. The elements in a file path are separated by slash ('/', U+002F) characters, regardless of host operating system convention.
type InternalFuncTableType ¶
type InternalFuncTableType struct { InternalFunc InternalFuncType `json:"-"` // if true then if InternalFunc != nil, then call it. InternalFuncName string `json:"InternalFunc"` // string name to lookkup InteralFunc by }
type InternalFuncType ¶
type PreRuleType ¶
type PreRuleType struct { IfMatch string // StripPrefix string // UseRoot string // StatusOnMatch RuleStatus // Fx UrlModifyFunc // MatchData interface{} // IfFromSuffix string // From suffix .ts IfToSuffix []string // To .js CommandToRun string // typescript {{.f_base}}.ts ReRun bool // if false(default) then check timestamps on input->output, else just run every time }
type RebuildFlag ¶
type RebuildFlag int
const ( NeedRebuild RebuildFlag = 1 TimestampsInOrder RebuildFlag = 2 )
func CompareModTime ¶
func CompareModTime(in, out time.Time) RebuildFlag
return true if modification time for in is after out
func (RebuildFlag) String ¶
func (nr RebuildFlag) String() string
type RuleStatus ¶
type RuleStatus int
const ( PreSuccess RuleStatus = iota // Use this result - it matched. PreFail // Fail all results, return 404 PreNext // Do not use this, proceed to next, if no next then 404 PreReplace // Function returns new root and or new name for file )
func ResolveFnThemeUser ¶
func ResolveFnThemeUser(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, urlIn string, g *FSConfig, rulNo int) (urlOut string, rootOut string, stat RuleStatus, err error)
func UrlFileExt ¶
func UrlFileExt(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, urlIn string, g *FSConfig, rulNo int) (urlOut string, rootOut string, stat RuleStatus, err error)
func (RuleStatus) String ¶
func (rs RuleStatus) String() string
type UrlModifyFunc ¶
type UrlModifyFunc func(fcfg *FileServerType, www http.ResponseWriter, req *http.Request, urlIn string, g *FSConfig, rulNo int) (urlOut string, rootOut string, stat RuleStatus, err error)