Feat(Initial): Initial Go codebase
All checks were successful
Webhook-Everything/Webhook-Everything/pipeline/head This commit looks good
All checks were successful
Webhook-Everything/Webhook-Everything/pipeline/head This commit looks good
This commit is contained in:
34
backend/internal/webhookeverything/main.go
Normal file
34
backend/internal/webhookeverything/main.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package webhookeverything
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"git.samuelpua.com/telboon/webhook-everything/backend/internal/telegrampackage"
|
||||
"github.com/go-chi/chi"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Env struct {
|
||||
DB *gorm.DB
|
||||
TelegramEnv *telegrampackage.Env
|
||||
HostUrl string
|
||||
}
|
||||
|
||||
func WebhookEverythingRoutes(db *gorm.DB, telegramEnv *telegrampackage.Env, hostURL string) chi.Router {
|
||||
var env Env
|
||||
env.DB = db
|
||||
env.TelegramEnv = telegramEnv
|
||||
|
||||
// Seed random
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
// Web Routes
|
||||
r := chi.NewRouter()
|
||||
r.HandleFunc("/routes/{routeID}", env.handleWebhook)
|
||||
|
||||
// Telegram handlers
|
||||
env.TelegramEnv.AddTelegramHandlerFunc(env.registerWebhook)
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user