Skip to content

Commit

Permalink
chore: update go libs (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag authored Jan 9, 2023
1 parent 3930503 commit b1b2287
Show file tree
Hide file tree
Showing 50 changed files with 186 additions and 195 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

_ "github.com/bombsimon/logrusr/v3"
"github.com/formancehq/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/formancehq/go-libs/otlp/otlptraces"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -68,7 +68,7 @@ func rootCommand() *cobra.Command {
server.Flags().Bool(authBearerUseScopesFlag,
false, "Use scopes as defined by rfc https://datatracker.ietf.org/doc/html/rfc8693")

sharedotlptraces.InitOTLPTracesFlags(server.Flags())
otlptraces.InitOTLPTracesFlags(server.Flags())

viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))
viper.AutomaticEnv()
Expand Down
52 changes: 26 additions & 26 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"strings"

"github.com/formancehq/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/formancehq/go-libs/otlp/otlptraces"

"github.com/bombsimon/logrusr/v3"
"github.com/formancehq/payments/internal/app/api"
Expand All @@ -13,11 +13,11 @@ import (

"github.com/Shopify/sarama"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/formancehq/go-libs/sharedlogging"
"github.com/formancehq/go-libs/sharedlogging/sharedlogginglogrus"
"github.com/formancehq/go-libs/sharedpublish"
"github.com/formancehq/go-libs/sharedpublish/sharedpublishhttp"
"github.com/formancehq/go-libs/sharedpublish/sharedpublishkafka"
"github.com/formancehq/go-libs/logging"
"github.com/formancehq/go-libs/logging/logginglogrus"
"github.com/formancehq/go-libs/publish"
"github.com/formancehq/go-libs/publish/publishhttp"
"github.com/formancehq/go-libs/publish/publishkafka"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -76,41 +76,41 @@ func runServer(cmd *cobra.Command, args []string) error {
}

options = append(options, databaseOptions)
options = append(options, sharedotlptraces.CLITracesModule(viper.GetViper()))
options = append(options, otlptraces.CLITracesModule(viper.GetViper()))

options = append(options,
fx.Provide(fx.Annotate(func(p message.Publisher) *sharedpublish.TopicMapperPublisher {
return sharedpublish.NewTopicMapperPublisher(p, topicsMapping())
}, fx.As(new(sharedpublish.Publisher)))))
fx.Provide(fx.Annotate(func(p message.Publisher) *publish.TopicMapperPublisher {
return publish.NewTopicMapperPublisher(p, topicsMapping())
}, fx.As(new(publish.Publisher)))))

options = append(options, api.HTTPModule())
options = append(options, sharedpublish.Module())
options = append(options, publish.Module())

switch {
case viper.GetBool(publisherHTTPEnabledFlag):
options = append(options, sharedpublishhttp.Module())
options = append(options, publishhttp.Module())
case viper.GetBool(publisherKafkaEnabledFlag):
options = append(options,
sharedpublishkafka.Module(serviceName, viper.GetStringSlice(publisherKafkaBrokerFlag)...),
sharedpublishkafka.ProvideSaramaOption(
sharedpublishkafka.WithConsumerReturnErrors(),
sharedpublishkafka.WithProducerReturnSuccess(),
publishkafka.Module(serviceName, viper.GetStringSlice(publisherKafkaBrokerFlag)...),
publishkafka.ProvideSaramaOption(
publishkafka.WithConsumerReturnErrors(),
publishkafka.WithProducerReturnSuccess(),
),
)

if viper.GetBool(publisherKafkaTLSEnabled) {
options = append(options, sharedpublishkafka.ProvideSaramaOption(sharedpublishkafka.WithTLS()))
options = append(options, publishkafka.ProvideSaramaOption(publishkafka.WithTLS()))
}

if viper.GetBool(publisherKafkaSASLEnabled) {
options = append(options, sharedpublishkafka.ProvideSaramaOption(
sharedpublishkafka.WithSASLEnabled(),
sharedpublishkafka.WithSASLCredentials(
options = append(options, publishkafka.ProvideSaramaOption(
publishkafka.WithSASLEnabled(),
publishkafka.WithSASLCredentials(
viper.GetString(publisherKafkaSASLUsername),
viper.GetString(publisherKafkaSASLPassword),
),
sharedpublishkafka.WithSASLMechanism(sarama.SASLMechanism(viper.GetString(publisherKafkaSASLMechanism))),
sharedpublishkafka.WithSASLScramClient(setSCRAMClient),
publishkafka.WithSASLMechanism(sarama.SASLMechanism(viper.GetString(publisherKafkaSASLMechanism))),
publishkafka.WithSASLScramClient(setSCRAMClient),
))
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ func setLogger() {
log.SetFormatter(&logrus.JSONFormatter{})
}

sharedlogging.SetFactory(sharedlogging.StaticLoggerFactory(sharedlogginglogrus.New(log)))
logging.SetFactory(logging.StaticLoggerFactory(logginglogrus.New(log)))

// Add a dedicated logger for opentelemetry in case of error
otel.SetLogger(logrusr.New(logrus.New().WithField("component", "otlp")))
Expand Down Expand Up @@ -178,14 +178,14 @@ func setSCRAMClient() sarama.SCRAMClient {

switch viper.GetInt(publisherKafkaSASLScramSHASize) {
case 512:
fn = sharedpublishkafka.SHA512
fn = publishkafka.SHA512
case 256:
fn = sharedpublishkafka.SHA256
fn = publishkafka.SHA256
default:
panic("sha size not handled")
}

return &sharedpublishkafka.XDGSCRAMClient{
return &publishkafka.XDGSCRAMClient{
HashGeneratorFcn: fn,
}
}
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ require (
github.com/ThreeDotsLabs/watermill v1.1.1
github.com/bombsimon/logrusr/v3 v3.1.0
github.com/davecgh/go-spew v1.1.1
github.com/formancehq/go-libs v1.3.0
github.com/formancehq/go-libs/sharedapi v0.0.0-20221228150855-8e3cef21df97
github.com/formancehq/go-libs/sharedotlp v0.0.0-20221228150855-8e3cef21df97
github.com/formancehq/go-libs v1.4.1
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/jackc/pgx/v5 v5.2.0
Expand Down Expand Up @@ -60,7 +58,7 @@ require (
github.com/golang/glog v1.0.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand Down Expand Up @@ -115,7 +113,7 @@ require (
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
19 changes: 6 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,13 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/formancehq/go-libs v1.3.0 h1:Ogs/B9FcoGHl2yF0TeTrBoGejKQk0G7XH6pFwgCod3U=
github.com/formancehq/go-libs v1.3.0/go.mod h1:9pIcaXQR4O1biXDfhFurYJZw1piU6sJk+0Vqvu+92ng=
github.com/formancehq/go-libs/sharedapi v0.0.0-20221228150855-8e3cef21df97 h1:9pP+VnP7C7dJpWuPlayPainZ01kqcIVu13nSf1wMVto=
github.com/formancehq/go-libs/sharedapi v0.0.0-20221228150855-8e3cef21df97/go.mod h1:PMf25p7rXNJkc/LIwvf0AmGfAo1NqwQG+5emONMrurA=
github.com/formancehq/go-libs/sharedotlp v0.0.0-20221228150855-8e3cef21df97 h1:png26T7Aot5+xNIoI29jo5VNA19rr/t0cGYR6NYW5qI=
github.com/formancehq/go-libs/sharedotlp v0.0.0-20221228150855-8e3cef21df97/go.mod h1:sY3SY+G3EDNd9sELK6UbDYx3Ah+hJJsEnBU9Dq28ZSw=
github.com/formancehq/go-libs v1.4.1 h1:rUKfUyZFq9aid+JUIqKN8Mk80Lx06Bx7AreHj+9vyTo=
github.com/formancehq/go-libs v1.4.1/go.mod h1:IK1zDIGRPi/o8sSApIc1W0VC1Y0DGdADzxvpbqlD8fk=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI=
github.com/gibson042/canonicaljson-go v1.0.3/go.mod h1:DsLpJTThXyGNO+KZlI85C1/KDcImpP67k/RKVjcaEqo=
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=
github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
Expand Down Expand Up @@ -215,8 +209,8 @@ github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 h1:t7uX3JBHdVwAi3G7sSSdbsk8NfgA+LnUS88V/2EKaA0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0/go.mod h1:4OGVnY4qf2+gw+ssiHbW+pq4mo2yko94YxxMmXZ7jCA=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -298,7 +292,6 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -733,8 +726,8 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70=
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef h1:uQ2vjV/sHTsWSqdKeLqmwitzgvjMl7o4IdtHwUDXSJY=
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down
4 changes: 2 additions & 2 deletions internal/app/api/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/formancehq/payments/internal/app/models"
"github.com/formancehq/payments/internal/app/storage"

"github.com/formancehq/go-libs/sharedapi"
"github.com/formancehq/go-libs/api"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -95,7 +95,7 @@ func listAccountsHandler(repo listAccountsRepository) http.HandlerFunc {
}
}

err = json.NewEncoder(w).Encode(sharedapi.BaseResponse[[]*accountResponse]{
err = json.NewEncoder(w).Encode(api.BaseResponse[[]*accountResponse]{
Data: &data,
})
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions internal/app/api/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import (

"github.com/gorilla/mux"

"github.com/formancehq/go-libs/sharedapi"
"github.com/formancehq/go-libs/sharedlogging"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/logging"
"github.com/formancehq/payments/internal/app/integration"
)

func handleErrorBadRequest(w http.ResponseWriter, r *http.Request, err error) {
w.WriteHeader(http.StatusBadRequest)

sharedlogging.GetLogger(r.Context()).Error(err)
logging.GetLogger(r.Context()).Error(err)
// TODO: Opentracing
err = json.NewEncoder(w).Encode(sharedapi.ErrorResponse{
err = json.NewEncoder(w).Encode(api.ErrorResponse{
ErrorCode: http.StatusText(http.StatusBadRequest),
ErrorMessage: err.Error(),
})
Expand All @@ -37,9 +37,9 @@ func handleErrorBadRequest(w http.ResponseWriter, r *http.Request, err error) {
func handleError(w http.ResponseWriter, r *http.Request, err error) {
w.WriteHeader(http.StatusInternalServerError)

sharedlogging.GetLogger(r.Context()).Error(err)
logging.GetLogger(r.Context()).Error(err)
// TODO: Opentracing
err = json.NewEncoder(w).Encode(sharedapi.ErrorResponse{
err = json.NewEncoder(w).Encode(api.ErrorResponse{
ErrorCode: "INTERNAL",
ErrorMessage: err.Error(),
})
Expand Down
8 changes: 4 additions & 4 deletions internal/app/api/connectormodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/formancehq/payments/internal/app/storage"

"github.com/formancehq/go-libs/sharedlogging"
"github.com/formancehq/go-libs/sharedpublish"
"github.com/formancehq/go-libs/logging"
"github.com/formancehq/go-libs/publish"
"github.com/formancehq/payments/internal/app/ingestion"
"github.com/formancehq/payments/internal/app/integration"
"github.com/formancehq/payments/internal/app/task"
Expand All @@ -30,9 +30,9 @@ func addConnector[ConnectorConfig models.ConnectorConfigObject](loader integrati
) fx.Option {
return fx.Options(
fx.Provide(func(store *storage.Storage,
publisher sharedpublish.Publisher,
publisher publish.Publisher,
) *integration.ConnectorManager[ConnectorConfig] {
logger := sharedlogging.GetLogger(context.Background())
logger := logging.GetLogger(context.Background())

schedulerFactory := integration.TaskSchedulerFactoryFn(func(
resolver task.Resolver, maxTasks int,
Expand Down
34 changes: 17 additions & 17 deletions internal/app/api/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"strings"
"time"

"github.com/formancehq/go-libs/sharedapi"
"github.com/formancehq/go-libs/sharedlogging"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/logging"

"github.com/formancehq/payments/internal/app/connectors/bankingcircle"
"github.com/formancehq/payments/internal/app/connectors/currencycloud"

"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/oauth2/oauth2introspect"
"github.com/formancehq/go-libs/sharedauth"
sharedotlp "github.com/formancehq/go-libs/sharedotlp/pkg"
"github.com/formancehq/go-libs/otlp"
"github.com/formancehq/payments/internal/app/connectors/dummypay"
"github.com/formancehq/payments/internal/app/connectors/modulr"
"github.com/formancehq/payments/internal/app/connectors/stripe"
Expand Down Expand Up @@ -77,7 +77,7 @@ func HTTPModule() fx.Option {

func httpRecoveryFunc(ctx context.Context, e interface{}) {
if viper.GetBool(otelTracesFlag) {
sharedotlp.RecordAsError(ctx, e)
otlp.RecordAsError(ctx, e)
} else {
logrus.Errorln(e)
debug.PrintStack()
Expand All @@ -99,28 +99,28 @@ func httpServeFunc(handler http.Handler) http.Handler {
})
}

func sharedAuthMethods() []sharedauth.Method {
methods := make([]sharedauth.Method, 0)
func sharedAuthMethods() []auth.Method {
methods := make([]auth.Method, 0)

if viper.GetBool(authBasicEnabledFlag) {
credentials := sharedauth.Credentials{}
credentials := auth.Credentials{}

for _, kv := range viper.GetStringSlice(authBasicCredentialsFlag) {
parts := strings.SplitN(kv, ":", 2)
credentials[parts[0]] = sharedauth.Credential{
credentials[parts[0]] = auth.Credential{
Password: parts[1],
}
}

methods = append(methods, sharedauth.NewHTTPBasicMethod(credentials))
methods = append(methods, auth.NewHTTPBasicMethod(credentials))
}

if viper.GetBool(authBearerEnabledFlag) {
methods = append(methods, sharedauth.NewHttpBearerMethod(
sharedauth.NewIntrospectionValidator(
methods = append(methods, auth.NewHttpBearerMethod(
auth.NewIntrospectionValidator(
oauth2introspect.NewIntrospecter(viper.GetString(authBearerIntrospectURLFlag)),
viper.GetBool(authBearerAudiencesWildcardFlag),
sharedauth.AudienceIn(viper.GetStringSlice(authBearerAudienceFlag)...),
auth.AudienceIn(viper.GetStringSlice(authBearerAudienceFlag)...),
),
))
}
Expand All @@ -130,9 +130,9 @@ func sharedAuthMethods() []sharedauth.Method {

func handleServerError(w http.ResponseWriter, r *http.Request, err error) {
w.WriteHeader(http.StatusInternalServerError)
sharedlogging.GetLogger(r.Context()).Error(err)
logging.GetLogger(r.Context()).Error(err)
// TODO: Opentracing
err = json.NewEncoder(w).Encode(sharedapi.ErrorResponse{
err = json.NewEncoder(w).Encode(api.ErrorResponse{
ErrorCode: "INTERNAL",
ErrorMessage: err.Error(),
})
Expand All @@ -143,9 +143,9 @@ func handleServerError(w http.ResponseWriter, r *http.Request, err error) {

func handleValidationError(w http.ResponseWriter, r *http.Request, err error) {
w.WriteHeader(http.StatusBadRequest)
sharedlogging.GetLogger(r.Context()).Error(err)
logging.GetLogger(r.Context()).Error(err)
// TODO: Opentracing
err = json.NewEncoder(w).Encode(sharedapi.ErrorResponse{
err = json.NewEncoder(w).Encode(api.ErrorResponse{
ErrorCode: "VALIDATION",
ErrorMessage: err.Error(),
})
Expand Down
Loading

0 comments on commit b1b2287

Please sign in to comment.