-
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
1 parent
5b27dca
commit 70c5e1b
Showing
17 changed files
with
764 additions
and
614 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
Large diffs are not rendered by default.
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
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
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