Skip to content

Commit

Permalink
simplify conditions (#6)
Browse files Browse the repository at this point in the history
Co-authored-by: Edgar Weber <[email protected]>
  • Loading branch information
marat-42 and Edgar Weber authored Feb 23, 2023
1 parent acfeb0b commit faabf52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions config/base_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ type Config struct {
}

func (c *Config) Validate() error {
if c.Debug {
if c.Logger == nil {
c.Logger = log.Default()
}
if c.Debug && c.Logger == nil {
c.Logger = log.Default()
}
if c.DeniedStatusCode == 0 {
c.DeniedStatusCode = http.StatusForbidden
Expand Down
6 changes: 2 additions & 4 deletions fiber_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ func NewFiberMiddleware(cfg *config.Config, input FiberInputCreationMethod) (*Fi
if err != nil {
return nil, err
}
if input == nil {
if cfg.InputCreationMethod == nil {
return nil, errors.New("[opa-middleware-fiber] InputCreationMethod must be provided")
}
if input == nil && cfg.InputCreationMethod == nil {
return nil, errors.New("[opa-middleware-fiber] InputCreationMethod must be provided")
}
return &FiberMiddleware{
Config: cfg,
Expand Down

0 comments on commit faabf52

Please sign in to comment.