mirror of
https://github.com/Smaug123/gitea-repo-config
synced 2025-10-19 05:48:41 +00:00
Add refresh-auth (#64)
This commit is contained in:
32
Gitea.Declarative/Utils.fs
Normal file
32
Gitea.Declarative/Utils.fs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace Gitea.Declarative
|
||||
|
||||
open System
|
||||
open System.Net.Http
|
||||
open Microsoft.Extensions.Logging.Console
|
||||
open Microsoft.Extensions.Options
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module internal Utils =
|
||||
|
||||
let createLoggerProvider () =
|
||||
let options =
|
||||
let options = ConsoleLoggerOptions ()
|
||||
|
||||
{ new IOptionsMonitor<ConsoleLoggerOptions> with
|
||||
member _.Get _ = options
|
||||
member _.CurrentValue = options
|
||||
|
||||
member _.OnChange _ =
|
||||
{ new IDisposable with
|
||||
member _.Dispose () = ()
|
||||
}
|
||||
}
|
||||
|
||||
new ConsoleLoggerProvider (options)
|
||||
|
||||
let createHttpClient (host : Uri) (apiKey : string) =
|
||||
let client = new HttpClient ()
|
||||
client.BaseAddress <- host
|
||||
client.DefaultRequestHeaders.Add ("Authorization", $"token {apiKey}")
|
||||
|
||||
client
|
Reference in New Issue
Block a user