From 574807d25465cd1919d4ccf9a8ecd36ee8a0b889 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Fri, 8 Nov 2024 16:52:19 +0300 Subject: [PATCH] set the africastalking POST route using env --- .env.example | 3 +++ cmd/africastalking/main.go | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index ab370a7..29b935e 100644 --- a/.env.example +++ b/.env.example @@ -16,3 +16,6 @@ CREATE_ACCOUNT_URL=http://localhost:5003/api/v2/account/create TRACK_STATUS_URL=https://custodial.sarafu.africa/api/track/ BALANCE_URL=https://custodial.sarafu.africa/api/account/status/ TRACK_URL=http://localhost:5003/api/v2/account/status + +#AfricasTalking USSD POST endpoint +AT_ENDPOINT=/ussd/africastalking diff --git a/cmd/africastalking/main.go b/cmd/africastalking/main.go index 7616473..bae83b9 100644 --- a/cmd/africastalking/main.go +++ b/cmd/africastalking/main.go @@ -29,10 +29,10 @@ import ( ) var ( - logg = logging.NewVanilla() - scriptDir = path.Join("services", "registration") - InfoLogger *log.Logger - ErrorLogger *log.Logger + logg = logging.NewVanilla() + scriptDir = path.Join("services", "registration") + InfoLogger *log.Logger + ErrorLogger *log.Logger ) func init() { @@ -197,9 +197,13 @@ func main() { rp := &atRequestParser{} bsh := handlers.NewBaseSessionHandler(cfg, rs, stateStore, userdataStore, rp, hl) sh := httpserver.NewATSessionHandler(bsh) + + mux := http.NewServeMux() + mux.Handle(initializers.GetEnv("AT_ENDPOINT", "/"), sh) + s := &http.Server{ Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))), - Handler: sh, + Handler: mux, } s.RegisterOnShutdown(sh.Shutdown)