package http

import (
	"context"
	"git.gocasts.ir/ebhomengo/niki/pkg/httpserver"
)

type Server struct {
	handler    Handler
	HTTPServer *httpserver.Server
}

func NewServer(handler Handler, hS *httpserver.Server) Server {
	return Server{handler: handler, HTTPServer: hS}
}

func (s Server) Serve() error {
	s.registerRoutes()
	if err := s.HTTPServer.Start(); err != nil {
		return err
	}

	return nil
}

func (s Server) Stop(ctx context.Context) error {
	return s.HTTPServer.Stop(ctx)
}

func (s Server) registerRoutes() {
	router := s.HTTPServer.GetRouter()

	router.GET("campaign/health-check", s.healthCheck)

	r := router.Group("campaign")
	
	r.POST("/", s.handler.createCampaign)

}
