package ocssapi import ( "net/http" "time" "github.com/rs/zerolog/log" "git.coopgo.io/coopgo-platform/carpool-service/handler" "git.coopgo.io/coopgo-platform/carpool-service/interoperability/ocss" "github.com/spf13/viper" ) type OCSSApiService struct { Handler *handler.CarpoolServiceHandler } func NewOCSSApiService(handler *handler.CarpoolServiceHandler) (*OCSSApiService, error) { return &OCSSApiService{ Handler: handler, }, nil } // Status func (s *OCSSApiService) Status() error { return nil } func Run(done chan error, cfg *viper.Viper, handler *handler.CarpoolServiceHandler) { var ( address = ":" + cfg.GetString("services.ocss_api.port") ) service, err := NewOCSSApiService(handler) if err != nil { log.Fatal().Err(err).Msg("could not initialize OCSS api service") return } err = http.ListenAndServe(address, ocss.NewServer(service)) srv := &http.Server{ Handler: ocss.NewServer(service), Addr: address, WriteTimeout: 15 * time.Second, ReadTimeout: 15 * time.Second, } err = srv.ListenAndServe() log.Error().Err(err).Msg("OCSS api error") done <- err }