Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ package main

import (
"github.com/devtron-labs/central-api/api"
"github.com/devtron-labs/central-api/api/currency"
util "github.com/devtron-labs/central-api/client"
"github.com/devtron-labs/central-api/internal/logger"
"github.com/devtron-labs/central-api/pkg"
currencyPkg "github.com/devtron-labs/central-api/pkg/currency"
blob_storage "github.com/devtron-labs/common-lib/blob-storage"
"github.com/devtron-labs/common-lib/utils"
"github.com/google/wire"
)

func InitializeApp() (*App, error) {
wire.Build(
logger.NewSugardLogger,
utils.NewSugardLogger,
//sql.PgSqlWireSet,
//releaseNote.NewReleaseNoteRepositoryImpl,
//wire.Bind(new(releaseNote.ReleaseNoteRepository), new(*releaseNote.ReleaseNoteRepositoryImpl)),
Expand All @@ -52,6 +54,15 @@ func InitializeApp() (*App, error) {
pkg.NewCiBuildMetadataServiceImpl,
wire.Bind(new(pkg.CiBuildMetadataService), new(*pkg.CiBuildMetadataServiceImpl)),

// Currency service dependencies
currencyPkg.NewCurrencyConfig,
currencyPkg.NewServiceImpl,
wire.Bind(new(currencyPkg.Service), new(*currencyPkg.ServiceImpl)),
currency.NewCurrencyRestHandlerImpl,
wire.Bind(new(currency.CurrencyRestHandler), new(*currency.CurrencyRestHandlerImpl)),
currency.NewRouter,
wire.Bind(new(currency.Router), new(*currency.RouterImpl)),

// S3 Upload Service
pkg.NewS3UploadServiceImpl,
wire.Bind(new(pkg.S3UploadService), new(*pkg.S3UploadServiceImpl)),
Expand Down
11 changes: 6 additions & 5 deletions api/RestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package api

import (
"encoding/json"
"github.com/Masterminds/semver"
"github.com/devtron-labs/central-api/api/handler"
util "github.com/devtron-labs/central-api/client"
Expand Down Expand Up @@ -258,13 +259,13 @@ func isVersionNewer(v1, v2 string) bool {
// SubmitFeedback handles the feedback submission endpoint
func (impl *RestHandlerImpl) SubmitFeedback(w http.ResponseWriter, r *http.Request) {
impl.logger.Info("received feedback submission request")
setupResponse(&w, r)
handler.SetupCorsOriginHeader(&w, r)

// Read request body
body, err := ioutil.ReadAll(r.Body)
if err != nil {
impl.logger.Errorw("error reading request body", "err", err)
impl.WriteJsonResp(w, err, "Failed to read request body", http.StatusBadRequest)
handler.WriteJsonResp(w, err, "Failed to read request body", http.StatusBadRequest)
return
}
defer r.Body.Close()
Expand All @@ -274,7 +275,7 @@ func (impl *RestHandlerImpl) SubmitFeedback(w http.ResponseWriter, r *http.Reque
err = json.Unmarshal(body, &feedbackData)
if err != nil {
impl.logger.Errorw("error unmarshalling feedback request", "err", err)
impl.WriteJsonResp(w, err, "Invalid request format", http.StatusBadRequest)
handler.WriteJsonResp(w, err, "Invalid request format", http.StatusBadRequest)
return
}

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

Expand All @@ -299,5 +300,5 @@ func (impl *RestHandlerImpl) SubmitFeedback(w http.ResponseWriter, r *http.Reque
"ucid": feedbackData.UCID,
"s3Url": feedbackData.FullConversationURL,
}
impl.WriteJsonResp(w, nil, response, http.StatusOK)
handler.WriteJsonResp(w, nil, response, http.StatusOK)
}
15 changes: 12 additions & 3 deletions wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading