Skip to content

Commit

Permalink
Fix to read the path of static contents from yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ybkuroki committed Feb 21, 2021
1 parent fc25f65 commit 89d977a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions application.develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ extension:
log:
request_log_format: ${remote_ip} ${account_name} ${uri} ${method} ${status}

staticcontents:
path: ./public/

security:
auth_path:
- /api/.*
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type Config struct {
Log struct {
RequestLogFormat string `yaml:"request_log_format" default:"${remote_ip} ${account_name} ${uri} ${method} ${status}"`
}
StaticContents struct {
Path string `yaml:"path"`
}
Security struct {
AuthPath []string `yaml:"auth_path"`
ExculdePath []string `yaml:"exclude_path"`
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func main() {
middleware.InitLoggerMiddleware(e, context)
middleware.InitSessionMiddleware(e, context)

e.Static("/", "./public/")
if conf.StaticContents.Path != "" {
e.Static("/", conf.StaticContents.Path)
logger.GetZapLogger().Infof("Served the static contents. path: " + conf.StaticContents.Path)
}

if err := e.Start(":8080"); err != nil {
logger.GetZapLogger().Errorf(err.Error())
Expand Down

0 comments on commit 89d977a

Please sign in to comment.