Implemented symlinks and mimetype for serve
This commit is contained in:
parent
523e519a3b
commit
605dc5352c
5 changed files with 81 additions and 16 deletions
17
config.go
17
config.go
|
|
@ -10,10 +10,11 @@ import (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
Listen string `toml:"listen"`
|
||||
Root string `toml:"root"`
|
||||
Hidden bool `toml:"hidden"`
|
||||
Footer string `toml:"footer"`
|
||||
Listen string `toml:"listen"`
|
||||
Root string `toml:"root"`
|
||||
Hidden bool `toml:"hidden"`
|
||||
Footer string `toml:"footer"`
|
||||
FollowSymlinks bool `toml:"follow_symlinks"`
|
||||
}
|
||||
|
||||
func loadConfig(path string) (*Config, error) {
|
||||
|
|
@ -22,9 +23,15 @@ func loadConfig(path string) (*Config, error) {
|
|||
return nil, err
|
||||
}
|
||||
cfg := &Config{}
|
||||
if err := toml.Unmarshal(b, cfg); err != nil {
|
||||
md, err := toml.Decode(string(b), cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", path, err)
|
||||
}
|
||||
// follow_symlinks defaults to true: symlinks are served as a window onto
|
||||
// their target, even outside root.
|
||||
if !md.IsDefined("follow_symlinks") {
|
||||
cfg.FollowSymlinks = true
|
||||
}
|
||||
if cfg.Root == "" {
|
||||
return nil, errors.New(`config: "root" is required`)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue