-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#102) ContentProxy: finish working FileCache
- Loading branch information
Showing
7 changed files
with
130 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Emulsion.TestFramework | ||
|
||
open System.Net.Http | ||
|
||
type SimpleHttpClientFactory() = | ||
interface IHttpClientFactory with | ||
member this.CreateClient _ = new HttpClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
namespace Emulsion.TestFramework | ||
|
||
open System | ||
open System.Net | ||
open System.Net.Sockets | ||
|
||
open Microsoft.AspNetCore.Builder | ||
open Microsoft.AspNetCore.Http | ||
|
||
module private NetUtil = | ||
let findFreePort() = | ||
use socket = new Socket(SocketType.Stream, ProtocolType.Tcp) | ||
socket.Bind(IPEndPoint(IPAddress.Loopback, 0)) | ||
(socket.LocalEndPoint :?> IPEndPoint).Port | ||
|
||
type WebFileStorage(data: Map<string, byte[]>) = | ||
let url = $"http://localhost:{NetUtil.findFreePort()}" | ||
|
||
let startWebApplication() = | ||
let builder = WebApplication.CreateBuilder() | ||
let app = builder.Build() | ||
app.MapGet("/{entry}", Func<_, _>(fun (entry: string) -> task { | ||
return Results.Bytes(data[entry]) | ||
})) |> ignore | ||
app, app.RunAsync url | ||
|
||
let app, task = startWebApplication() | ||
|
||
member _.Link(entry: string): Uri = | ||
failwith "todo" | ||
Uri $"{url}/{entry}" | ||
|
||
member _.Content(entry: string): byte[] = | ||
failwith "todo" | ||
data[entry] | ||
|
||
interface IDisposable with | ||
member this.Dispose(): unit = failwith "todo" | ||
|
||
member this.Dispose(): unit = | ||
app.StopAsync().Wait() | ||
task.Wait() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters