forked from ebhomengo/niki
Changed struct
This commit is contained in:
parent
6c48741646
commit
6c96b349ab
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
paymentapp "git.gocasts.ir/ebhomengo/niki/domain/payment"
|
||||
paymentapp "git.gocasts.ir/ebhomengo/niki/paymentapp"
|
||||
"git.gocasts.ir/ebhomengo/niki/pkg/database"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
package http
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/domain/payment/service"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
service *service.PaymentService
|
||||
}
|
||||
|
||||
func NewHandler(service *service.PaymentService) *Handler {
|
||||
return &Handler{
|
||||
service: service,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) HealthCheck(c echo.Context) error {
|
||||
return c.String(200, "HealthCheck is ok")
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
httpserver "git.gocasts.ir/ebhomengo/niki/pkg/http_server"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
httpServer httpserver.Server
|
||||
handler *Handler
|
||||
}
|
||||
|
||||
func NewServer(httpServer httpserver.Server, handler *Handler) *Server {
|
||||
return &Server{
|
||||
httpServer: httpServer,
|
||||
handler: handler,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) Serve() error {
|
||||
s.registerRoutes()
|
||||
return s.httpServer.Start()
|
||||
}
|
||||
|
||||
func (s *Server) Stop(ctx context.Context) error {
|
||||
return s.httpServer.Stop(ctx)
|
||||
}
|
||||
|
||||
func (s *Server) registerRoutes() {
|
||||
paymentGroup := s.httpServer.Router.Group("/payment")
|
||||
|
||||
paymentGroup.GET("/health", s.handler.HealthCheck)
|
||||
}
|
||||
|
|
@ -3,27 +3,23 @@ package paymentapp
|
|||
import (
|
||||
"context"
|
||||
|
||||
paymenthttp "git.gocasts.ir/ebhomengo/niki/domain/payment/delivery/http"
|
||||
"git.gocasts.ir/ebhomengo/niki/pkg/database"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
server *paymenthttp.Server
|
||||
}
|
||||
|
||||
func Setup(ctx context.Context, cfg Config, conn *database.Database) (*App, error) {
|
||||
|
||||
//TODO Setup
|
||||
|
||||
return &App{
|
||||
server: nil,
|
||||
}, nil
|
||||
return &App{}, nil
|
||||
}
|
||||
|
||||
func (a *App) Start() error {
|
||||
return a.server.Serve()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) Stop(ctx context.Context) error {
|
||||
return a.server.Stop(ctx)
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,13 +1,5 @@
|
|||
package paymentapp
|
||||
|
||||
type HTTPConfig struct {
|
||||
Addr string `yaml:"addr" json:"addr"`
|
||||
Port int
|
||||
ReadTimeout int `yaml:"read_timeout" json:"read_timeout"`
|
||||
WriteTimeout int `yaml:"write_timeout" json:"write_timeout"`
|
||||
IdleTimeout int `yaml:"idle_timeout" json:"idle_timeout"`
|
||||
AllowOrigins []string
|
||||
}
|
||||
type PostgresConfig struct {
|
||||
Host string `yaml:"host"`
|
||||
Port int `yaml:"port"`
|
||||
|
|
@ -27,7 +19,6 @@ type LoggerConfig struct {
|
|||
}
|
||||
|
||||
type Config struct {
|
||||
HTTP HTTPConfig `yaml:"http" json:"http"`
|
||||
Postgres PostgresConfig `yaml:"postgres" json:"postgres"`
|
||||
Logger LoggerConfig `yaml:"logger" json:"logger"`
|
||||
}
|
||||
Loading…
Reference in New Issue