Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata to get one subscription #757

Merged
merged 1 commit into from
Jun 11, 2022
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
2 changes: 1 addition & 1 deletion docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2022-06-11 17:01:18.028523 +0100 WAT m=+70.571493876
// 2022-06-11 19:49:53.437188319 +0100 WAT m=+92.916961153
package docs

import (
Expand Down
34 changes: 24 additions & 10 deletions server/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,34 @@ func (a *applicationHandler) GetSubscription(w http.ResponseWriter, r *http.Requ
return
}

source, err := a.sourceService.FindSourceByID(r.Context(), group, subscription.SourceID)
if err != nil {
_ = render.Render(w, r, newServiceErrResponse(err))
return
if subscription.SourceID != "" {
source, err := a.sourceService.FindSourceByID(r.Context(), group, subscription.SourceID)
if err != nil {
_ = render.Render(w, r, newServiceErrResponse(err))
return
}
subscription.Source = source
}

endpoint, err := a.appRepo.FindApplicationEndpointByID(r.Context(), subscription.AppID, subscription.EndpointID)
if err != nil {
_ = render.Render(w, r, newServiceErrResponse(err))
return
if subscription.EndpointID != "" {
endpoint, err := a.appRepo.FindApplicationEndpointByID(r.Context(), subscription.AppID, subscription.EndpointID)
if err != nil {
_ = render.Render(w, r, newServiceErrResponse(err))
return
}

subscription.Endpoint = endpoint
}

subscription.Source = source
subscription.Endpoint = endpoint
if subscription.AppID != "" {
app, err := a.appRepo.FindApplicationByID(r.Context(), subscription.AppID)
if err != nil {
_ = render.Render(w, r, newServiceErrResponse(err))
return
}

subscription.App = app
}

_ = render.Render(w, r, newServerResponse("Subscription fetched successfully", subscription, http.StatusOK))
}
Expand Down