Reset to safe template with azure deploy option
This commit is contained in:
@@ -8,29 +8,37 @@ open Giraffe
|
||||
open Saturn
|
||||
open Shared
|
||||
|
||||
open Microsoft.WindowsAzure.Storage
|
||||
|
||||
let tryGetEnv = System.Environment.GetEnvironmentVariable >> function null | "" -> None | x -> Some x
|
||||
|
||||
let publicPath = Path.GetFullPath "../Client/public"
|
||||
let publicPath = tryGetEnv "public_path" |> Option.defaultValue "../Client/public" |> Path.GetFullPath
|
||||
let storageAccount = tryGetEnv "STORAGE_CONNECTIONSTRING" |> Option.defaultValue "UseDevelopmentStorage=true" |> CloudStorageAccount.Parse
|
||||
|
||||
let port =
|
||||
"SERVER_PORT"
|
||||
|> tryGetEnv |> Option.map uint16 |> Option.defaultValue 8085us
|
||||
|
||||
// let webApp = router {
|
||||
// get "/api/init" (fun next ctx ->
|
||||
// task {
|
||||
// let counter = {Value = 7}
|
||||
// return! json counter next ctx
|
||||
// })
|
||||
// }
|
||||
let webApp = router {
|
||||
get "/api/init" (fun next ctx ->
|
||||
task {
|
||||
let counter = {Value = 42}
|
||||
return! json counter next ctx
|
||||
})
|
||||
}
|
||||
|
||||
let configureAzure (services:IServiceCollection) =
|
||||
tryGetEnv "APPINSIGHTS_INSTRUMENTATIONKEY"
|
||||
|> Option.map services.AddApplicationInsightsTelemetry
|
||||
|> Option.defaultValue services
|
||||
|
||||
let app = application {
|
||||
url ("http://0.0.0.0:" + port.ToString() + "/")
|
||||
//use_router webApp
|
||||
use_router webApp
|
||||
memory_cache
|
||||
use_static publicPath
|
||||
use_json_serializer(Thoth.Json.Giraffe.ThothSerializer())
|
||||
service_config configureAzure
|
||||
use_gzip
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user