parent
65f4281f92
commit
f01a8ff592
25
docs/docs.go
25
docs/docs.go
@ -29,6 +29,27 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"/articles/by/sourceid": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Articles"
|
||||
],
|
||||
"summary": "Finds the articles based on the SourceID provided. Returns the top 50.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Source ID UUID",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/articles/by/tag": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
@ -41,7 +62,7 @@ const docTemplate = `{
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Tag name",
|
||||
"name": "Tag",
|
||||
"name": "tag",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
@ -497,7 +518,7 @@ const docTemplate = `{
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "0.1",
|
||||
Host: "",
|
||||
Host: "localhost:8081",
|
||||
BasePath: "/api",
|
||||
Schemes: []string{},
|
||||
Title: "NewsBot collector",
|
||||
|
@ -5,6 +5,7 @@
|
||||
"contact": {},
|
||||
"version": "0.1"
|
||||
},
|
||||
"host": "localhost:8081",
|
||||
"basePath": "/api",
|
||||
"paths": {
|
||||
"/articles": {
|
||||
@ -20,6 +21,27 @@
|
||||
}
|
||||
},
|
||||
"/articles/by/sourceid": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Articles"
|
||||
],
|
||||
"summary": "Finds the articles based on the SourceID provided. Returns the top 50.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Source ID UUID",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/articles/by/tag": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
@ -32,7 +54,7 @@
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Tag name",
|
||||
"name": "Tag",
|
||||
"name": "tag",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
basePath: /api
|
||||
host: localhost:8081
|
||||
info:
|
||||
contact: {}
|
||||
title: NewsBot collector
|
||||
@ -27,11 +28,26 @@ paths:
|
||||
tags:
|
||||
- Articles
|
||||
/articles/by/sourceid:
|
||||
get:
|
||||
parameters:
|
||||
- description: Source ID UUID
|
||||
in: query
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses: {}
|
||||
summary: Finds the articles based on the SourceID provided. Returns the top
|
||||
50.
|
||||
tags:
|
||||
- Articles
|
||||
/articles/by/tag:
|
||||
get:
|
||||
parameters:
|
||||
- description: Tag name
|
||||
in: query
|
||||
name: Tag
|
||||
name: tag
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
|
7
main.go
7
main.go
@ -10,11 +10,10 @@ import (
|
||||
"github.com/jtom38/newsbot/collector/services/cron"
|
||||
)
|
||||
|
||||
|
||||
|
||||
// @title NewsBot collector
|
||||
// @version 0.1
|
||||
// @BasePath /api
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
c := cron.New(ctx)
|
||||
@ -26,5 +25,7 @@ func main() {
|
||||
fmt.Println("API: http://localhost:8081/api")
|
||||
fmt.Println("Swagger: http://localhost:8081/swagger/index.html")
|
||||
err := http.ListenAndServe(":8081", server.Router)
|
||||
if err != nil { panic(err) }
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@ -99,16 +99,16 @@ func (s *Server) GetArticlesBySourceId(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO add page support
|
||||
// GetArticlesByTag
|
||||
// @Summary Finds the articles based on the SourceID provided. Returns the top 50.
|
||||
// @Param Tag query string true "Tag name"
|
||||
// @Param tag query string true "Tag name"
|
||||
// @Produce application/json
|
||||
// @Tags Articles
|
||||
// @Router /articles/by/sourceid [get]
|
||||
// @Router /articles/by/tag [get]
|
||||
func (s *Server) GetArticlesByTag(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
r.URL.Query()
|
||||
query := r.URL.Query()
|
||||
_id := query["id"][0]
|
||||
_id := query["tag"][0]
|
||||
|
||||
uuid, err := uuid.Parse(_id)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user