From 90e739a56ef9636c086e2122418611a4d65a9347 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Tue, 31 Jan 2023 08:19:23 -0800 Subject: [PATCH] Features/get route updates (#37) * cleaned up get routes * added a func to query articles by page * removed unused imports * merged page with listArticles as a optional --- database/query.sql.go | 49 +++++++++++++++++ database/schema/query.sql | 6 +++ docs/docs.go | 8 +++ docs/swagger.json | 8 +++ docs/swagger.yaml | 5 ++ dto/articles.go | 18 +++++++ routes/articles.go | 111 ++++++++++++++++++-------------------- routes/discordwebhooks.go | 53 +++++------------- routes/queue.go | 23 +++----- routes/server.go | 16 +++++- routes/sources.go | 58 ++++---------------- routes/subscriptions.go | 61 +++++---------------- 12 files changed, 202 insertions(+), 214 deletions(-) diff --git a/database/query.sql.go b/database/query.sql.go index 96b4f9b..34f2a84 100644 --- a/database/query.sql.go +++ b/database/query.sql.go @@ -948,6 +948,55 @@ func (q *Queries) ListArticlesByDate(ctx context.Context, limit int32) ([]Articl return items, nil } +const listArticlesByPage = `-- name: ListArticlesByPage :many +select id, sourceid, tags, title, url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage from articles +order by pubdate desc +offset $2 +fetch next $1 rows only +` + +type ListArticlesByPageParams struct { + Limit int32 + Offset int32 +} + +func (q *Queries) ListArticlesByPage(ctx context.Context, arg ListArticlesByPageParams) ([]Article, error) { + rows, err := q.db.QueryContext(ctx, listArticlesByPage, arg.Limit, arg.Offset) + if err != nil { + return nil, err + } + defer rows.Close() + var items []Article + for rows.Next() { + var i Article + if err := rows.Scan( + &i.ID, + &i.Sourceid, + &i.Tags, + &i.Title, + &i.Url, + &i.Pubdate, + &i.Video, + &i.Videoheight, + &i.Videowidth, + &i.Thumbnail, + &i.Description, + &i.Authorname, + &i.Authorimage, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const listDiscordQueueItems = `-- name: ListDiscordQueueItems :many Select id, articleid from DiscordQueue LIMIT $1 ` diff --git a/database/schema/query.sql b/database/schema/query.sql index 4c28e94..fea4e64 100644 --- a/database/schema/query.sql +++ b/database/schema/query.sql @@ -35,6 +35,12 @@ Left Join sources On articles.sourceid = sources.id Where name = $1; +-- name: ListArticlesByPage :many +select * from articles +order by pubdate desc +offset $2 +fetch next $1 rows only; + -- name: CreateArticle :exec INSERT INTO Articles (ID, SourceId, Tags, Title, Url, PubDate, Video, VideoHeight, VideoWidth, Thumbnail, Description, AuthorName, AuthorImage) diff --git a/docs/docs.go b/docs/docs.go index f8eba2b..4e0cd8a 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -25,6 +25,14 @@ const docTemplate = `{ "Articles" ], "summary": "Lists the top 50 records", + "parameters": [ + { + "type": "string", + "description": "page number", + "name": "page", + "in": "query" + } + ], "responses": { "200": { "description": "OK", diff --git a/docs/swagger.json b/docs/swagger.json index 4eed4d9..f18beb2 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -16,6 +16,14 @@ "Articles" ], "summary": "Lists the top 50 records", + "parameters": [ + { + "type": "string", + "description": "page number", + "name": "page", + "in": "query" + } + ], "responses": { "200": { "description": "OK", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 3996964..1970414 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -241,6 +241,11 @@ info: paths: /articles: get: + parameters: + - description: page number + in: query + name: page + type: string produces: - application/json responses: diff --git a/dto/articles.go b/dto/articles.go index f04797a..bc37498 100644 --- a/dto/articles.go +++ b/dto/articles.go @@ -35,6 +35,24 @@ func (c DtoClient) ListArticles(ctx context.Context, limit int) ([]models.Articl return res, nil } +func (c DtoClient) ListArticlesByPage(ctx context.Context, page, limit int32 ) ([]models.ArticleDto, error) { + var res []models.ArticleDto + + a, err := c.db.ListArticlesByPage(ctx, database.ListArticlesByPageParams{ + Limit: limit, + Offset: page * limit, + }) + if err != nil { + return res, err + } + + for _, article := range a { + res = append(res, c.convertArticle(article)) + } + + return res, nil +} + func (c DtoClient) GetArticle(ctx context.Context, ID uuid.UUID) (models.ArticleDto, error) { a, err := c.db.GetArticleByID(ctx, ID) if err != nil { diff --git a/routes/articles.go b/routes/articles.go index c7accd6..1773d2b 100644 --- a/routes/articles.go +++ b/routes/articles.go @@ -1,8 +1,9 @@ package routes import ( - "encoding/json" + "fmt" "net/http" + "strconv" "github.com/go-chi/chi/v5" "github.com/google/uuid" @@ -27,9 +28,20 @@ type ArticlesListResults struct { Payload []models.ArticleDto `json:"payload"` } +type ArticleGetResults struct { + ApiStatusModel + Payload models.ArticleDto `json:"payload"` +} + +type ArticleDetailsResult struct { + ApiStatusModel + Payload models.ArticleDetailsDto `json:"payload"` +} + // ListArticles // @Summary Lists the top 50 records // @Produce application/json +// @Param page query string false "page number" // @Tags Articles // @Router /articles [get] // @Success 200 {object} ArticlesListResults "OK" @@ -41,27 +53,34 @@ func (s *Server) listArticles(w http.ResponseWriter, r *http.Request) { }, } - w.Header().Set(HeaderContentType, ApplicationJson) + query := r.URL.Query() + queryPage := query["page"] + fmt.Printf("queryPage: %v\n", queryPage) + + // if a page number was sent, process it + if len(queryPage) == 1 { + page, err := strconv.Atoi(query["page"][0]) + if err != nil { + s.WriteError(w, err.Error(), http.StatusBadRequest) + return + } - res, err := s.dto.ListArticles(r.Context(), 50) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return + res, err := s.dto.ListArticlesByPage(r.Context(), int32(page), 50) + if err != nil { + s.WriteError(w, err.Error(), http.StatusInternalServerError) + return + } + p.Payload = res + s.WriteJson(w, p) + } else { + res, err := s.dto.ListArticles(r.Context(), 50) + if err != nil { + s.WriteError(w, err.Error(), http.StatusInternalServerError) + return + } + p.Payload = res + s.WriteJson(w, p) } - - p.Payload = res - - bres, err := json.Marshal(p) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - w.Write(bres) -} - -type ArticleGetResults struct { - ApiStatusModel - Payload models.ArticleDto `json:"payload"` } // GetArticle @@ -72,15 +91,13 @@ type ArticleGetResults struct { // @Router /articles/{ID} [get] // @Success 200 {object} ArticleGetResults "OK" func (s *Server) getArticle(w http.ResponseWriter, r *http.Request) { - p := ArticleGetResults { + p := ArticleGetResults{ ApiStatusModel: ApiStatusModel{ - Message: "OK", + Message: "OK", StatusCode: http.StatusOK, }, } - w.Header().Set(HeaderContentType, ApplicationJson) - id := chi.URLParam(r, "ID") uuid, err := uuid.Parse(id) if err != nil { @@ -96,18 +113,7 @@ func (s *Server) getArticle(w http.ResponseWriter, r *http.Request) { p.Payload = res - bres, err := json.Marshal(p) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bres) -} - -type ArticleDetailsResult struct { - ApiStatusModel - Payload models.ArticleDetailsDto `json:"payload"` + s.WriteJson(w, p) } // GetArticleDetails @@ -118,15 +124,13 @@ type ArticleDetailsResult struct { // @Router /articles/{ID}/details [get] // @Success 200 {object} ArticleDetailsResult "OK" func (s *Server) getArticleDetails(w http.ResponseWriter, r *http.Request) { - p := ArticleDetailsResult { + p := ArticleDetailsResult{ ApiStatusModel: ApiStatusModel{ Message: "OK", StatusCode: http.StatusOK, }, } - w.Header().Set(HeaderContentType, ApplicationJson) - id := chi.URLParam(r, "ID") uuid, err := uuid.Parse(id) if err != nil { @@ -142,18 +146,7 @@ func (s *Server) getArticleDetails(w http.ResponseWriter, r *http.Request) { p.Payload = res - bres, err := json.Marshal(p) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bres) -} - -type ArticlesBySourceIDResults struct { - ApiStatusModel - Payload []models.ArticleDto `json:"payload"` + s.WriteJson(w, p) } // TODO add page support @@ -165,7 +158,12 @@ type ArticlesBySourceIDResults struct { // @Router /articles/by/sourceid [get] // @Success 200 {object} ArticlesListResults "OK" func (s *Server) GetArticlesBySourceId(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") + p := ArticlesListResults{ + ApiStatusModel: ApiStatusModel{ + Message: "OK", + StatusCode: http.StatusOK, + }, + } r.URL.Query() query := r.URL.Query() @@ -182,12 +180,7 @@ func (s *Server) GetArticlesBySourceId(w http.ResponseWriter, r *http.Request) { s.WriteError(w, err.Error(), http.StatusInternalServerError) return } + p.Payload = res - bres, err := json.Marshal(res) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bres) + s.WriteJson(w, p) } diff --git a/routes/discordwebhooks.go b/routes/discordwebhooks.go index eaee584..97591ce 100644 --- a/routes/discordwebhooks.go +++ b/routes/discordwebhooks.go @@ -12,6 +12,16 @@ import ( "github.com/jtom38/newsbot/collector/domain/models" ) +type ListDiscordWebhooks struct { + ApiStatusModel + Payload []models.DiscordWebHooksDto `json:"payload"` +} + +type GetDiscordWebhook struct { + ApiStatusModel + Payload models.DiscordWebHooksDto `json:"payload"` +} + func (s Server) DiscordWebHookRouter() http.Handler { r := chi.NewRouter() @@ -28,11 +38,6 @@ func (s Server) DiscordWebHookRouter() http.Handler { return r } -type ListDiscordWebhooks struct { - ApiStatusModel - Payload []models.DiscordWebHooksDto `json:"payload"` -} - // ListDiscordWebhooks // @Summary Returns the top 100 entries from the queue to be processed. // @Produce application/json @@ -46,27 +51,13 @@ func (s *Server) ListDiscordWebHooks(w http.ResponseWriter, r *http.Request) { }, } - w.Header().Set(HeaderContentType, ApplicationJson) - res, err := s.dto.ListDiscordWebHooks(r.Context(), 50) if err != nil { s.WriteError(w, err.Error(), http.StatusInternalServerError) return } p.Payload = res - - bres, err := json.Marshal(p) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bres) -} - -type GetDiscordWebhook struct { - ApiStatusModel - Payload models.DiscordWebHooksDto `json:"payload"` + s.WriteJson(w, p) } // GetDiscordWebHook @@ -84,8 +75,6 @@ func (s *Server) GetDiscordWebHooksById(w http.ResponseWriter, r *http.Request) }, } - w.Header().Set(HeaderContentType, ApplicationJson) - _id := chi.URLParam(r, "ID") if _id == "" { s.WriteError(w, "id is missing", http.StatusBadRequest) @@ -104,14 +93,7 @@ func (s *Server) GetDiscordWebHooksById(w http.ResponseWriter, r *http.Request) return } p.Payload = res - - bres, err := json.Marshal(p) - if err != nil { - s.WriteError(w, "unable to convert to json", http.StatusBadRequest) - return - } - - w.Write(bres) + s.WriteJson(w, p) } // GetDiscordWebHookByServerAndChannel @@ -130,8 +112,6 @@ func (s *Server) GetDiscordWebHooksByServerAndChannel(w http.ResponseWriter, r * }, } - w.Header().Set(HeaderContentType, ApplicationJson) - query := r.URL.Query() _server := query["server"][0] if _server == "" { @@ -152,14 +132,7 @@ func (s *Server) GetDiscordWebHooksByServerAndChannel(w http.ResponseWriter, r * } p.Payload = res - - bres, err := json.Marshal(p) - if err != nil { - s.WriteError(w, "unable to convert to json", http.StatusInternalServerError) - return - } - - w.Write(bres) + s.WriteJson(w, p) } // NewDiscordWebHook diff --git a/routes/queue.go b/routes/queue.go index dddb5a6..a43b296 100644 --- a/routes/queue.go +++ b/routes/queue.go @@ -1,13 +1,17 @@ package routes import ( - "encoding/json" "net/http" "github.com/go-chi/chi/v5" "github.com/jtom38/newsbot/collector/domain/models" ) +type ListDiscordWebHooksQueueResults struct { + ApiStatusModel + Payload []models.DiscordQueueDetailsDto `json:"payload"` +} + func (s *Server) GetQueueRouter() http.Handler { r := chi.NewRouter() @@ -16,11 +20,6 @@ func (s *Server) GetQueueRouter() http.Handler { return r } -type ListDiscordWebHooksQueueResults struct { - ApiStatusModel - Payload []models.DiscordQueueDetailsDto `json:"payload"` -} - // GetDiscordQueue // @Summary Returns the top 100 entries from the queue to be processed. // @Produce application/json @@ -28,8 +27,6 @@ type ListDiscordWebHooksQueueResults struct { // @Router /queue/discord/webhooks [get] // @Success 200 {object} ListDiscordWebHooksQueueResults "ok" func (s *Server) ListDiscordWebhookQueue(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - p := ListDiscordWebHooksQueueResults{ ApiStatusModel: ApiStatusModel{ Message: "OK", @@ -45,13 +42,5 @@ func (s *Server) ListDiscordWebhookQueue(w http.ResponseWriter, r *http.Request) } p.Payload = res - - // convert to json - b, err := json.Marshal(p) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(b) + s.WriteJson(w, p) } diff --git a/routes/server.go b/routes/server.go index 5b74b47..952a457 100644 --- a/routes/server.go +++ b/routes/server.go @@ -100,15 +100,27 @@ type ApiError struct { func (s *Server) WriteError(w http.ResponseWriter, errMessage string, HttpStatusCode int) { e := ApiError{ ApiStatusModel: &ApiStatusModel{ - StatusCode: http.StatusInternalServerError, + StatusCode: HttpStatusCode, Message: errMessage, }, } b, err := json.Marshal(e) if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + http.Error(w, err.Error(), HttpStatusCode) } w.Write(b) } + +func (s *Server) WriteJson(w http.ResponseWriter, model interface{}) { + w.Header().Set(HeaderContentType, ApplicationJson) + + bres, err := json.Marshal(model) + if err != nil { + s.WriteError(w, err.Error(), http.StatusInternalServerError) + return + } + + w.Write(bres) +} \ No newline at end of file diff --git a/routes/sources.go b/routes/sources.go index 6d11892..d0ba5f4 100644 --- a/routes/sources.go +++ b/routes/sources.go @@ -61,8 +61,7 @@ func (s *Server) listSources(w http.ResponseWriter, r *http.Request) { res, err := s.Db.ListSources(*s.ctx, int32(topInt)) */ - w.Header().Set(HeaderContentType, ApplicationJson) - result := ListSources{ + p := ListSources{ ApiStatusModel: ApiStatusModel{ StatusCode: http.StatusOK, Message: "OK", @@ -76,15 +75,8 @@ func (s *Server) listSources(w http.ResponseWriter, r *http.Request) { return } - result.Payload = items - - bResult, err := json.Marshal(result) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bResult) + p.Payload = items + s.WriteJson(w, p) } // ListSourcesBySource @@ -106,9 +98,8 @@ func (s *Server) listSourcesBySource(w http.ResponseWriter, r *http.Request) { } res, err := s.Db.ListSources(*s.ctx, int32(topInt)) */ - w.Header().Set(HeaderContentType, ApplicationJson) - result := ListSources{ + p := ListSources{ ApiStatusModel: ApiStatusModel{ StatusCode: http.StatusOK, Message: "OK", @@ -116,24 +107,16 @@ func (s *Server) listSourcesBySource(w http.ResponseWriter, r *http.Request) { } query := r.URL.Query() - _source := query["source"][0] // Shows the list by Sources.source - res, err := s.dto.ListSourcesBySource(r.Context(), _source) + res, err := s.dto.ListSourcesBySource(r.Context(), query["source"][0]) if err != nil { s.WriteError(w, err.Error(), http.StatusBadRequest) return } - result.Payload = res - - bResult, err := json.Marshal(result) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bResult) + p.Payload = res + s.WriteJson(w, p) } // GetSource @@ -154,10 +137,7 @@ func (s *Server) getSources(w http.ResponseWriter, r *http.Request) { }, } - w.Header().Set(HeaderContentType, ApplicationJson) - - id := chi.URLParam(r, "ID") - uuid, err := uuid.Parse(id) + uuid, err := uuid.Parse(chi.URLParam(r, "ID")) if err != nil { s.WriteError(w, err.Error(), http.StatusBadRequest) return @@ -170,14 +150,7 @@ func (s *Server) getSources(w http.ResponseWriter, r *http.Request) { } payload.Payload = res - - bResult, err := json.Marshal(payload) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bResult) + s.WriteJson(w, payload) } // GetSourceByNameAndSource @@ -219,15 +192,7 @@ func (s *Server) GetSourceBySourceAndName(w http.ResponseWriter, r *http.Request } p.Payload = item - - bResult, err := json.Marshal(item) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Header().Set(HeaderContentType, ApplicationJson) - w.Write(bResult) + s.WriteJson(w, p) } // NewRedditSource @@ -242,8 +207,6 @@ func (s *Server) newRedditSource(w http.ResponseWriter, r *http.Request) { _url := query["url"][0] //_tags := query["tags"][0] - w.Header().Set("Content-Type", "application/json") - if _url == "" { s.WriteError(w, "url is missing a value", http.StatusBadRequest) return @@ -277,6 +240,7 @@ func (s *Server) newRedditSource(w http.ResponseWriter, r *http.Request) { s.WriteError(w, err.Error(), http.StatusInternalServerError) return } + //s.WriteJson(w, ¶ms) bJson, err := json.Marshal(¶ms) if err != nil { diff --git a/routes/subscriptions.go b/routes/subscriptions.go index 029a797..3d1deeb 100644 --- a/routes/subscriptions.go +++ b/routes/subscriptions.go @@ -34,6 +34,11 @@ type GetSubscription struct { Payload models.SubscriptionDto `json:"payload"` } +type ListSubscriptionDetails struct { + ApiStatusModel + Payload []models.SubscriptionDetailsDto `json:"payload"` +} + // GetSubscriptions // @Summary Returns the top 100 entries from the queue to be processed. // @Produce application/json @@ -43,8 +48,6 @@ type GetSubscription struct { // @Failure 400 {object} ApiError "Unable to reach SQL." // @Failure 500 {object} ApiError "Failed to process data from SQL." func (s *Server) ListSubscriptions(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - payload := ListSubscriptions{ ApiStatusModel: ApiStatusModel{ StatusCode: http.StatusOK, @@ -59,19 +62,7 @@ func (s *Server) ListSubscriptions(w http.ResponseWriter, r *http.Request) { } payload.Payload = res - - bres, err := json.Marshal(payload) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bres) -} - -type ListSubscriptionDetails struct { - ApiStatusModel - Payload []models.SubscriptionDetailsDto `json:"payload"` + s.WriteJson(w, payload) } // ListSubscriptionDetails @@ -80,8 +71,7 @@ type ListSubscriptionDetails struct { // @Tags Subscription // @Router /subscriptions/details [get] // @Success 200 {object} ListSubscriptionDetails "ok" -func (s Server) ListSubscriptionDetails(w http.ResponseWriter, r *http.Request) { - w.Header().Set(HeaderContentType, ApplicationJson) +func (s *Server) ListSubscriptionDetails(w http.ResponseWriter, r *http.Request) { payload := ListSubscriptionDetails{ ApiStatusModel: ApiStatusModel{ StatusCode: http.StatusOK, @@ -96,13 +86,7 @@ func (s Server) ListSubscriptionDetails(w http.ResponseWriter, r *http.Request) } payload.Payload = res - - b, err := json.Marshal(payload) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - } - - w.Write(b) + s.WriteJson(w, payload) } // GetSubscriptionsByDiscordId @@ -115,8 +99,6 @@ func (s Server) ListSubscriptionDetails(w http.ResponseWriter, r *http.Request) // @Failure 400 {object} ApiError "Unable to reach SQL or Data problems" // @Failure 500 {object} ApiError "Data problems" func (s *Server) GetSubscriptionsByDiscordId(w http.ResponseWriter, r *http.Request) { - w.Header().Set(HeaderContentType, ApplicationJson) - p := ListSubscriptions{ ApiStatusModel: ApiStatusModel{ StatusCode: http.StatusOK, @@ -125,13 +107,12 @@ func (s *Server) GetSubscriptionsByDiscordId(w http.ResponseWriter, r *http.Requ } query := r.URL.Query() - _id := query["id"][0] - if _id == "" { + if query["id"][0] == "" { s.WriteError(w, ErrIdValueMissing, http.StatusBadRequest) return } - uuid, err := uuid.Parse(_id) + uuid, err := uuid.Parse(query["id"][0]) if err != nil { s.WriteError(w, ErrValueNotUuid, http.StatusBadRequest) return @@ -144,14 +125,7 @@ func (s *Server) GetSubscriptionsByDiscordId(w http.ResponseWriter, r *http.Requ } p.Payload = res - - bres, err := json.Marshal(p) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bres) + s.WriteJson(w, p) } // GetSubscriptionsBySourceId @@ -162,8 +136,6 @@ func (s *Server) GetSubscriptionsByDiscordId(w http.ResponseWriter, r *http.Requ // @Router /subscriptions/by/SourceId [get] // @Success 200 {object} ListSubscriptions "ok" func (s *Server) GetSubscriptionsBySourceId(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - p := ListSubscriptions{ ApiStatusModel: ApiStatusModel{ StatusCode: http.StatusOK, @@ -191,14 +163,7 @@ func (s *Server) GetSubscriptionsBySourceId(w http.ResponseWriter, r *http.Reque } p.Payload = res - - bres, err := json.Marshal(p) - if err != nil { - s.WriteError(w, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(bres) + s.WriteJson(w, p) } // NewDiscordWebHookSubscription @@ -208,8 +173,6 @@ func (s *Server) GetSubscriptionsBySourceId(w http.ResponseWriter, r *http.Reque // @Tags Subscription // @Router /subscriptions/discord/webhook/new [post] func (s *Server) newDiscordWebHookSubscription(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - // Extract the values given query := r.URL.Query() discordWebHookId := query["discordWebHookId"][0]