-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dusan Malusev <dusan@dusanmalusev.dev>
- Loading branch information
1 parent
71aee20
commit 13c9ab9
Showing
29 changed files
with
507 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,17 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/spf13/viper" | ||
|
||
"github.com/BrosSquad/GoFiber-Boilerplate/app/constants" | ||
utilsconfig "github.com/nano-interactive/go-utils/config" | ||
) | ||
|
||
type ( | ||
App struct { | ||
FiberInfo bool `mapstructure:"fiber_info" json:"fiber_info" yaml:"fiber_info"` | ||
} | ||
Logging struct { | ||
Level string `mapstructure:"level" json:"level" yaml:"level"` | ||
PrettyPrint bool `mapstructure:"pretty_print" json:"pretty_print" yaml:"pretty_print"` | ||
} | ||
|
||
HTTP struct { | ||
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` | ||
Port int `mapstructure:"port" json:"port" yaml:"port"` | ||
} | ||
|
||
Config struct { | ||
Logging Logging `mapstructure:"logging" json:"logging" yaml:"logging"` | ||
HTTP HTTP `mapstructure:"http" json:"http" yaml:"http"` | ||
App App `mapstructure:"app" json:"app" yaml:"app"` | ||
} | ||
) | ||
|
||
func New() (Config, error) { | ||
cfg := utilsconfig.Config{ | ||
ProjectName: constants.AppName, | ||
Name: "config", | ||
Type: "yaml", | ||
Paths: []string{ | ||
"$XDG_CONFIG_HOME/" + constants.AppName, | ||
"/etc/" + constants.AppName, | ||
".", | ||
}, | ||
} | ||
|
||
v, err := utilsconfig.NewWithModifier(cfg) | ||
if err != nil { | ||
return Config{}, err | ||
} | ||
|
||
return NewWithViper(v) | ||
} | ||
|
||
func NewWithViper(v *viper.Viper) (Config, error) { | ||
c := Config{} | ||
|
||
if err := v.Unmarshal(&c); err != nil { | ||
return Config{}, err | ||
} | ||
|
||
return c, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package config | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
type HTTP struct { | ||
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` | ||
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" json:"shutdown_timeout" yaml:"shutdown_timeout"` | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package handlers | ||
|
||
import ( | ||
"github.com/BrosSquad/GoFiber-Boilerplate/app/handlers/helloworld" | ||
"github.com/BrosSquad/GoFiber-Boilerplate/core/fiber/fiberfx" | ||
) | ||
|
||
func Handlers() fiberfx.RoutesFx { | ||
return fiberfx.Routes( | ||
"/", | ||
nil, | ||
fiberfx.Get("/", helloworld.HelloWorld), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
app: | ||
fiber_info: true | ||
|
||
http: | ||
addr: '0.0.0.0' | ||
port: 8080 | ||
addr: '0.0.0.0:8080' | ||
shutdown_timeout: 1s | ||
profiler_addr: '0.0.0.0:5000' | ||
|
||
|
||
logging: | ||
level: debug | ||
pretty_print: true |
Oops, something went wrong.