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 { OperatorId string Handler *handler.CarpoolServiceHandler } func NewOCSSApiService(cfg *viper.Viper, handler *handler.CarpoolServiceHandler) (*OCSSApiService, error) { return &OCSSApiService{ OperatorId: cfg.GetString("standards.ocss.operator_id"), 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(cfg, handler) if err != nil { log.Fatal().Err(err).Msg("could not initialize OCSS api service") return } server := ocss.NewServer(service) server.AddOperator("mobilaude_preprod", "wxvSwUpTTZ5wiAxrHpPfDsijz88w6tMW") server.AuthorizedOperators = append(server.AuthorizedOperators, ocss.AuthorizedOperator{ Operator: "mobilaude", ApiKey: "$2y$10$TJuDZDu.mqy5dDKGMSfxSO5f6pz/36XVrAyQ1CXJd63ccjRlX7gpC", }) srv := &http.Server{ Handler: server, Addr: address, WriteTimeout: 15 * time.Second, ReadTimeout: 15 * time.Second, } err = srv.ListenAndServe() log.Error().Err(err).Msg("OCSS api error") done <- err }