Feature/dynamic swagger uri (#15)
* made the swagger uri based on env * updated swagger to reflect the dynamic uri * updated extamples
This commit is contained in:
parent
f01a8ff592
commit
79f3383fdc
@ -15,6 +15,7 @@ This is the collection service of newsbot to pull articles from the web.
|
||||
2. `curl -X 'GET' 'http://localhost:8081/api/config/sources' -H 'accept: application/json'`
|
||||
6. Add any new sources
|
||||
7. Add a Discord Web Hook
|
||||
1. `curl -X 'POST' 'http://localhost:8081/api/discord/webhooks/new?url=WEBHOOKURL&server=SERVERNAME&channel=CHANNELNAME' -H 'accept: application/json' -d ''`
|
||||
8. Create your subscription links
|
||||
1. This is a link between a source and a discord web hook. Without this, the app will not send a notification about new posts.
|
||||
|
||||
|
@ -7,6 +7,8 @@ services:
|
||||
api:
|
||||
image: ghcr.io/jtom38/newsbot.collector.api:master
|
||||
environment:
|
||||
SERVER_ADDRESS: "localhost"
|
||||
|
||||
SQL_CONNECTION_STRING: "host=localhost user=postgres password=postgres dbname=postgres sslmode=disable"
|
||||
|
||||
# Used for database migrations
|
||||
@ -21,6 +23,7 @@ services:
|
||||
# Enable/Disable YouTube monitoring
|
||||
FEATURE_ENABLE_YOUTUBE_BACKEND: false
|
||||
|
||||
FEATURE_ENABLE_TWITCH_BACKEND: false
|
||||
# Set your Twitch Developer ID and Secrets here and they will be used to collect updates.
|
||||
TWITCH_CLIENT_ID: ""
|
||||
TWITCH_CLIENT_SECRET: ""
|
||||
|
@ -518,7 +518,7 @@ const docTemplate = `{
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "0.1",
|
||||
Host: "localhost:8081",
|
||||
Host: "",
|
||||
BasePath: "/api",
|
||||
Schemes: []string{},
|
||||
Title: "NewsBot collector",
|
||||
|
@ -5,7 +5,6 @@
|
||||
"contact": {},
|
||||
"version": "0.1"
|
||||
},
|
||||
"host": "localhost:8081",
|
||||
"basePath": "/api",
|
||||
"paths": {
|
||||
"/articles": {
|
||||
|
@ -1,5 +1,4 @@
|
||||
basePath: /api
|
||||
host: localhost:8081
|
||||
info:
|
||||
contact: {}
|
||||
title: NewsBot collector
|
||||
|
15
main.go
15
main.go
@ -4,17 +4,21 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
_ "github.com/jtom38/newsbot/collector/docs"
|
||||
|
||||
"github.com/jtom38/newsbot/collector/docs"
|
||||
"github.com/jtom38/newsbot/collector/routes"
|
||||
"github.com/jtom38/newsbot/collector/services/config"
|
||||
"github.com/jtom38/newsbot/collector/services/cron"
|
||||
)
|
||||
|
||||
// @title NewsBot collector
|
||||
// @version 0.1
|
||||
// @BasePath /api
|
||||
|
||||
func main() {
|
||||
cfg := config.New()
|
||||
address := cfg.GetConfig(config.ServerAddress)
|
||||
docs.SwaggerInfo.Host = fmt.Sprintf("%v:8081", address)
|
||||
|
||||
ctx := context.Background()
|
||||
c := cron.New(ctx)
|
||||
c.Start()
|
||||
@ -22,8 +26,9 @@ func main() {
|
||||
server := routes.NewServer(ctx)
|
||||
|
||||
fmt.Println("API is online and waiting for requests.")
|
||||
fmt.Println("API: http://localhost:8081/api")
|
||||
fmt.Println("Swagger: http://localhost:8081/swagger/index.html")
|
||||
fmt.Printf("API: http://%v:8081/api\r\n", address)
|
||||
fmt.Printf("Swagger: http://%v:8081/swagger/index.html\r\n", address)
|
||||
|
||||
err := http.ListenAndServe(":8081", server.Router)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
DB_URI string = "DB_URI"
|
||||
ServerAddress = "SERVER_ADDRESS"
|
||||
|
||||
Sql_Connection_String string = "SQL_CONNECTION_STRING"
|
||||
Sql_Connection_String = "SQL_CONNECTION_STRING"
|
||||
|
||||
FEATURE_ENABLE_REDDIT_BACKEND = "FEATURE_ENABLE_REDDIT_BACKEND"
|
||||
REDDIT_PULL_TOP = "REDDIT_PULL_TOP"
|
||||
|
Loading…
Reference in New Issue
Block a user