James Tombleson
ff4075383a
* added a route to delete subscriptions based on the ID given * added a new route to find a record based on the name and source * added a route to query Discord Web Hooks by Server and Channel names * tested the endpoints and they seem good to test more * updated some routes for subscriptions and formatted files * removed debug file * fixing some panic calls * swag
37 lines
827 B
Go
37 lines
827 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"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()
|
|
|
|
server := routes.NewServer(ctx)
|
|
|
|
fmt.Println("API is online and waiting for requests.")
|
|
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)
|
|
}
|
|
}
|