cleanup file structure, dockerize app

This commit is contained in:
KS Jannette
2026-05-19 03:37:56 -04:00
parent 4042ba87f5
commit 8cfde57cab
18 changed files with 262 additions and 98 deletions

View File

@@ -6,7 +6,7 @@ import (
"net/http"
"time"
"github.com/kjannette/go-http-server/internal/config"
"github.com/kjannette/go_http_server/internal/config"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
"go.uber.org/zap"

View File

@@ -3,16 +3,17 @@ package main
import (
"context"
"github.com/felipecoppola/go-boilerplate/internal/config"
"github.com/felipecoppola/go-boilerplate/internal/infrastructure/os"
"github.com/kjannette/go_http_server/internal/config"
infrasignal "github.com/kjannette/go_http_server/internal/infrastructure/os"
_ "github.com/kjannette/go_http_server/pkg/logger"
"go.uber.org/zap"
)
// Globals that are set at build time.
var (
appName = ""
appVersion = ""
appName = "go-http-server"
appVersion = "dev"
)
func main() {
@@ -28,15 +29,15 @@ func main() {
cfg, err := config.NewConfig()
if err != nil {
logger.Error("error creating config: %w", zap.Error(err))
logger.Error("error creating config", zap.Error(err))
return
}
logger.Info("starting app")
os.SignalListener(logger, cancel)
infrasignal.SignalListener(logger, cancel)
if err = run(ctx, cfg); err != nil {
logger.Error("command failed: %w", zap.Error(err))
logger.Error("command failed", zap.Error(err))
return
}

View File

@@ -3,9 +3,8 @@ package main
import (
"context"
"github.com/kjannette/go-http-server/cmd/app/handler/httpjson"
"github.com/kjannnette/go-http-server/internal/config"
"github.com/kjannette/go-http-server/pkg/logger"
"github.com/kjannette/go_http_server/cmd/app/handler/httpjson"
"github.com/kjannette/go_http_server/internal/config"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
@@ -16,14 +15,13 @@ func run(ctx context.Context, cfg *config.Config) error {
eg, ctx := errgroup.WithContext(ctx)
app, h := httpjson.New(lg)
serverLog := lg.Named("run_server")
eg.Go(func(l logger.Logger) func() error {
return func() error {
l.Info("starting server")
defer l.Info("terminated server")
return h.RunServer(ctx, cfg, app)
}
}(lg.Named("run_server")))
eg.Go(func() error {
serverLog.Info("starting server")
defer serverLog.Info("terminated server")
return h.RunServer(ctx, cfg, app)
})
return eg.Wait()
}

View File

@@ -1,17 +0,0 @@
package main
import (
"context"
"github.com/kjannette/go-server/internal/config"
"github.com/kjannette/go-server/internal/infrastructure/os"
"go.uber.org/zap"
)
var (
appName = ""
appVarsion = ""
)
func main() {
defer func() {_ = zap.L().Sync() }()
}

View File