Skip to content

Commit

Permalink
updates routes to enable GET -> OK on any route
Browse files Browse the repository at this point in the history
  • Loading branch information
Szer authored Dec 25, 2023
1 parent 06acabf commit 17c2060
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/VahterBanBot/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,19 @@ getEnvWith "APPLICATIONINSIGHTS_CONNECTION_STRING" (fun appInsightKey ->
%builder.Logging.AddConsole()

let webApp = choose [
// need for Azure health checks on / route
GET >=> route "/" >=> text "OK"

requiresApiKey >=> choose [
POST >=> route botConf.Route >=> bindJson<Update> (fun update next ctx -> task {
use scope = ctx.RequestServices.CreateScope()
let telegramClient = scope.ServiceProvider.GetRequiredService<ITelegramBotClient>()
let logger = ctx.GetLogger<Root>()
try
do! onUpdate telegramClient botConf (ctx.GetLogger "VahterBanBot.Bot") update.Message
with e ->
logger.LogError(e, "Unexpected error while processing update")
return! Successful.OK() next ctx
})
]
// need for Azure health checks on any route
GET >=> text "OK"

POST >=> route botConf.Route >=> requiresApiKey >=> bindJson<Update> (fun update next ctx -> task {
use scope = ctx.RequestServices.CreateScope()
let telegramClient = scope.ServiceProvider.GetRequiredService<ITelegramBotClient>()
let logger = ctx.GetLogger<Root>()
try
do! onUpdate telegramClient botConf (ctx.GetLogger "VahterBanBot.Bot") update.Message
with e ->
logger.LogError(e, "Unexpected error while processing update")
return! Successful.OK() next ctx
})
]

let app = builder.Build()
Expand Down

0 comments on commit 17c2060

Please sign in to comment.