Compare commits
1 Commits
main
...
features/g
Author | SHA1 | Date | |
---|---|---|---|
4b96aaf819 |
22
docs/docs.go
22
docs/docs.go
@ -104,6 +104,28 @@ const docTemplate = `{
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/config/sources/by/source": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Config",
|
||||
"Source"
|
||||
],
|
||||
"summary": "Lists the top 50 records based on the name given. Example: reddit",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Source Name",
|
||||
"name": "source",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/config/sources/new/reddit": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
@ -95,6 +95,28 @@
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/config/sources/by/source": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Config",
|
||||
"Source"
|
||||
],
|
||||
"summary": "Lists the top 50 records based on the name given. Example: reddit",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Source Name",
|
||||
"name": "source",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/config/sources/new/reddit": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
@ -118,6 +118,21 @@ paths:
|
||||
tags:
|
||||
- Config
|
||||
- Source
|
||||
/config/sources/by/source:
|
||||
get:
|
||||
parameters:
|
||||
- description: Source Name
|
||||
in: query
|
||||
name: source
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses: {}
|
||||
summary: 'Lists the top 50 records based on the name given. Example: reddit'
|
||||
tags:
|
||||
- Config
|
||||
- Source
|
||||
/config/sources/new/reddit:
|
||||
post:
|
||||
parameters:
|
||||
|
@ -93,6 +93,7 @@ func (s *Server) MountRoutes() {
|
||||
|
||||
/* Source Routes */
|
||||
s.Router.Get("/api/config/sources", s.listSources)
|
||||
s.Router.Get("/api/config/sources/by/source", s.listSourcesBySource)
|
||||
|
||||
/* Reddit Source Routes */
|
||||
|
||||
|
@ -28,12 +28,49 @@ func (s *Server) listSources(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := s.Db.ListSources(*s.ctx, int32(topInt))
|
||||
*/
|
||||
|
||||
// Default way of showing all sources
|
||||
res, err := s.Db.ListSources(*s.ctx, 50)
|
||||
if err != nil {
|
||||
http.Error(w, "url is missing a value", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
bResult, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
http.Error(w, "unable to convert to json", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(bResult)
|
||||
|
||||
}
|
||||
|
||||
// ListSourcesBySource
|
||||
// @Summary Lists the top 50 records based on the name given. Example: reddit
|
||||
// @Param source query string true "Source Name"
|
||||
// @Produce application/json
|
||||
// @Tags Config, Source
|
||||
// @Router /config/sources/by/source [get]
|
||||
func (s *Server) listSourcesBySource(w http.ResponseWriter, r *http.Request) {
|
||||
//TODO Add top?
|
||||
/*
|
||||
top := chi.URLParam(r, "top")
|
||||
topInt, err := strconv.ParseInt(top, 0, 32)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
res, err := s.Db.ListSources(*s.ctx, int32(topInt))
|
||||
*/
|
||||
|
||||
query := r.URL.Query()
|
||||
_source := query["source"][0]
|
||||
|
||||
// Shows the list by Sources.source
|
||||
res, err := s.Db.ListSourcesBySource(*s.ctx, strings.ToLower(_source))
|
||||
if err != nil {
|
||||
http.Error(w, "invalid source is missing a value", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
bResult, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
http.Error(w, "unable to convert to json", http.StatusBadRequest)
|
||||
@ -116,10 +153,6 @@ func (s *Server) newRedditSource(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(bJson)
|
||||
}
|
||||
|
||||
func (s *Server) getSourceByType(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
// NewYoutubeSource
|
||||
// @Summary Creates a new youtube source to monitor.
|
||||
// @Param name query string true "name"
|
||||
|
Loading…
Reference in New Issue
Block a user