enhance linting rules and update HTTP status codes in responses
Some checks failed
🧪 ✨ Unit Tests Workflow / 🔍 🐹 Go Tests (push) Failing after 1m11s

This commit is contained in:
2025-06-17 22:12:43 -04:00
parent 7efe11f845
commit ef073eadc2
3 changed files with 16 additions and 5 deletions

View File

@@ -10,6 +10,16 @@ linters:
- containedctx
- godot
- usestdlibvars
- funlen
- gochecknoglobals
- tagalign
- sqlclosecheck
- rowserrcheck
- recvcheck
- reassign
- predeclared
- maintidx
- mnd
formatters:
settings:

View File

@@ -4,6 +4,7 @@ import (
"gitea.siteworxpro.com/Siteworxpro/Go-Template/http_handlers/errors"
"gitea.siteworxpro.com/Siteworxpro/Go-Template/logger"
"github.com/labstack/echo/v4"
"net/http"
)
func Register(g *echo.Group) {
@@ -20,7 +21,7 @@ type index struct{}
func (i *index) Get(c echo.Context) error {
c.Get("logger").(logger.Interface).Info("Index handler called")
return c.JSON(200, map[string]string{"message": "Hello, World!"})
return c.JSON(http.StatusOK, map[string]string{"message": "Hello, World!"})
}
func (i *index) Post(c echo.Context) error {
@@ -28,11 +29,11 @@ func (i *index) Post(c echo.Context) error {
}
func (i *index) Put(c echo.Context) error {
return c.JSON(200, map[string]string{"message": "Hello, World!"})
return c.JSON(http.StatusOK, map[string]string{"message": "Hello, World!"})
}
func (i *index) Delete(c echo.Context) error {
return c.JSON(200, map[string]string{"message": "Hello, World!"})
return c.JSON(http.StatusOK, map[string]string{"message": "Hello, World!"})
}
func (i *index) Patch(c echo.Context) error {

View File

@@ -22,7 +22,7 @@ type Logger struct {
logger *log.Logger
}
func FromContext(ctx context.Context) Interface {
func FromContext(ctx context.Context) *Logger {
logger, ok := ctx.Value(contextKey).(*Logger)
if !ok {
return nil
@@ -31,7 +31,7 @@ func FromContext(ctx context.Context) Interface {
return logger
}
func NewLogger(level log.Level) Interface {
func NewLogger(level log.Level) *Logger {
l := log.New()
l.SetFormatter(&log.JSONFormatter{})
l.SetLevel(level)