James Tombleson
713205bb03
* basic routes are working with db context * swagger is working along with swag gen * cron was updated with a class and better db context, untested though * sourcelist command added * lost the pg package but added it back * Updated the api startup for cron and api * updated source routes and started to add article routes * Updated cron add func calls * updated swagger * keeping articles basic for now as I dont need to pull them in yet * swagger update * added getarticlesbysourceid call * adding the subscriptions table to track who to send notifications and where * removed legacy columns from discordwebhooks that are no longer needed. * added discord webhook routes * updated routes * Minor change to schema * Updated routes to support subscriptions * ignore .vscode
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package routes
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func RootRoutes() chi.Router {
|
|
app := chi.NewRouter()
|
|
app.Route("/", func(r chi.Router) {
|
|
r.Get("/helloworld", helloWorld)
|
|
r.Get("/ping", ping)
|
|
r.Route("/hello/{who}", func(r chi.Router) {
|
|
r.Get("/", helloWho)
|
|
})
|
|
})
|
|
return app
|
|
}
|
|
|
|
// HelloWorld
|
|
// @Summary Responds back with "Hello world!"
|
|
// @Produce plain
|
|
// @Tags debug
|
|
// @Router /helloworld [get]
|
|
func helloWorld(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte("Hello World!"))
|
|
}
|
|
|
|
// Ping
|
|
// @Summary Sends back "pong". Good to test with.
|
|
// @Produce plain
|
|
// @Tags debug
|
|
// @Router /ping [get]
|
|
func ping(w http.ResponseWriter, r *http.Request) {
|
|
msg := "pong"
|
|
w.Write([]byte(msg))
|
|
}
|
|
|
|
// HelloWho
|
|
// @Summary Responds back with "Hello x" depending on param passed in.
|
|
// @Param who path string true "Who"
|
|
// @Produce plain
|
|
// @Tags debug
|
|
// @Router /hello/{who} [get]
|
|
func helloWho(w http.ResponseWriter, r *http.Request) {
|
|
msg := fmt.Sprintf("Hello %v", chi.URLParam(r, "who"))
|
|
w.Write([]byte(msg))
|
|
}
|