-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace logrus and gorilla+negorni with zerolog and gin (#114)
* replace logrus and gorilla+negorni with zerolog and gin * fix swagger spec * use info when LOG_LEVEL not set * update base image in Dockerfile * fix base image * remove EXPOSE from Dockerfile * use default logger in watcher * rename watcher logger field * add requestId field to logger
- Loading branch information
1 parent
5b27dca
commit 32bc503
Showing
18 changed files
with
530 additions
and
402 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
run: | ||
timeout: 30m | ||
|
||
linters: | ||
enable: | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- unused | ||
- zerologlint | ||
|
||
issues: | ||
max-same-issues: 0 |
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
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,15 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
type Route struct { | ||
Path string | ||
Method string | ||
Handler gin.HandlerFunc | ||
} | ||
|
||
type Controller interface { | ||
GetRoutes() []Route | ||
} |
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,27 +1,25 @@ | ||
package controllers | ||
|
||
import ( | ||
"net/http" | ||
|
||
apiErrors "github.com/equinor/radix-job-scheduler/api/errors" | ||
models "github.com/equinor/radix-job-scheduler/models/common" | ||
"github.com/equinor/radix-job-scheduler/utils" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
type ControllerBase struct { | ||
} | ||
|
||
func (controller *ControllerBase) HandleError(w http.ResponseWriter, err error) { | ||
var status *models.Status | ||
func (controller *ControllerBase) HandleError(c *gin.Context, err error) { | ||
_ = c.Error(err) | ||
|
||
var status *models.Status | ||
switch t := err.(type) { | ||
case apiErrors.APIStatus: | ||
status = t.Status() | ||
default: | ||
status = apiErrors.NewFromError(err).Status() | ||
} | ||
|
||
log.Errorf("failed: %v", err) | ||
utils.StatusResponse(w, status) | ||
utils.StatusResponse(c.Writer, status) | ||
} |
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
Oops, something went wrong.