Skip to content

Commit 5ec4061

Browse files
committed
fix: main sync and wire fixes
1 parent 0f9f997 commit 5ec4061

3 files changed

Lines changed: 31 additions & 10 deletions

File tree

Wire.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ package main
2121

2222
import (
2323
"github.com/devtron-labs/central-api/api"
24+
"github.com/devtron-labs/central-api/api/currency"
2425
util "github.com/devtron-labs/central-api/client"
25-
"github.com/devtron-labs/central-api/internal/logger"
2626
"github.com/devtron-labs/central-api/pkg"
27+
currencyPkg "github.com/devtron-labs/central-api/pkg/currency"
2728
blob_storage "github.com/devtron-labs/common-lib/blob-storage"
29+
"github.com/devtron-labs/common-lib/utils"
2830
"github.com/google/wire"
2931
)
3032

3133
func InitializeApp() (*App, error) {
3234
wire.Build(
33-
logger.NewSugardLogger,
35+
utils.NewSugardLogger,
3436
//sql.PgSqlWireSet,
3537
//releaseNote.NewReleaseNoteRepositoryImpl,
3638
//wire.Bind(new(releaseNote.ReleaseNoteRepository), new(*releaseNote.ReleaseNoteRepositoryImpl)),
@@ -52,6 +54,15 @@ func InitializeApp() (*App, error) {
5254
pkg.NewCiBuildMetadataServiceImpl,
5355
wire.Bind(new(pkg.CiBuildMetadataService), new(*pkg.CiBuildMetadataServiceImpl)),
5456

57+
// Currency service dependencies
58+
currencyPkg.NewCurrencyConfig,
59+
currencyPkg.NewServiceImpl,
60+
wire.Bind(new(currencyPkg.Service), new(*currencyPkg.ServiceImpl)),
61+
currency.NewCurrencyRestHandlerImpl,
62+
wire.Bind(new(currency.CurrencyRestHandler), new(*currency.CurrencyRestHandlerImpl)),
63+
currency.NewRouter,
64+
wire.Bind(new(currency.Router), new(*currency.RouterImpl)),
65+
5566
// S3 Upload Service
5667
pkg.NewS3UploadServiceImpl,
5768
wire.Bind(new(pkg.S3UploadService), new(*pkg.S3UploadServiceImpl)),

api/RestHandler.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package api
1818

1919
import (
20+
"encoding/json"
2021
"github.com/Masterminds/semver"
2122
"github.com/devtron-labs/central-api/api/handler"
2223
util "github.com/devtron-labs/central-api/client"
@@ -258,13 +259,13 @@ func isVersionNewer(v1, v2 string) bool {
258259
// SubmitFeedback handles the feedback submission endpoint
259260
func (impl *RestHandlerImpl) SubmitFeedback(w http.ResponseWriter, r *http.Request) {
260261
impl.logger.Info("received feedback submission request")
261-
setupResponse(&w, r)
262+
handler.SetupCorsOriginHeader(&w, r)
262263

263264
// Read request body
264265
body, err := ioutil.ReadAll(r.Body)
265266
if err != nil {
266267
impl.logger.Errorw("error reading request body", "err", err)
267-
impl.WriteJsonResp(w, err, "Failed to read request body", http.StatusBadRequest)
268+
handler.WriteJsonResp(w, err, "Failed to read request body", http.StatusBadRequest)
268269
return
269270
}
270271
defer r.Body.Close()
@@ -274,7 +275,7 @@ func (impl *RestHandlerImpl) SubmitFeedback(w http.ResponseWriter, r *http.Reque
274275
err = json.Unmarshal(body, &feedbackData)
275276
if err != nil {
276277
impl.logger.Errorw("error unmarshalling feedback request", "err", err)
277-
impl.WriteJsonResp(w, err, "Invalid request format", http.StatusBadRequest)
278+
handler.WriteJsonResp(w, err, "Invalid request format", http.StatusBadRequest)
278279
return
279280
}
280281

@@ -287,7 +288,7 @@ func (impl *RestHandlerImpl) SubmitFeedback(w http.ResponseWriter, r *http.Reque
287288
err = impl.feedbackService.SubmitFeedback(&feedbackData)
288289
if err != nil {
289290
impl.logger.Errorw("error submitting feedback", "err", err, "ucid", feedbackData.UCID)
290-
impl.WriteJsonResp(w, err, "Failed to submit feedback", http.StatusInternalServerError)
291+
handler.WriteJsonResp(w, err, "Failed to submit feedback", http.StatusInternalServerError)
291292
return
292293
}
293294

@@ -299,5 +300,5 @@ func (impl *RestHandlerImpl) SubmitFeedback(w http.ResponseWriter, r *http.Reque
299300
"ucid": feedbackData.UCID,
300301
"s3Url": feedbackData.FullConversationURL,
301302
}
302-
impl.WriteJsonResp(w, nil, response, http.StatusOK)
303+
handler.WriteJsonResp(w, nil, response, http.StatusOK)
303304
}

wire_gen.go

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)