-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡️ optimize for single instance of HttpClient without factory
- Loading branch information
Showing
21 changed files
with
297 additions
and
123 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
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
namespace SurrealDb.Internals.Auth; | ||
|
||
internal class BasicAuth : IAuth | ||
{ | ||
public string Username { get; set; } = string.Empty; | ||
public string? Password { get; set; } | ||
} | ||
internal record BasicAuth(string Username, string? Password) : IAuth; |
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,6 +1,3 @@ | ||
namespace SurrealDb.Internals.Auth; | ||
|
||
internal class BearerAuth : IAuth | ||
{ | ||
public string Token { get; set; } = string.Empty; | ||
} | ||
internal record BearerAuth(string Token) : IAuth; |
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,3 +1,3 @@ | ||
namespace SurrealDb.Internals.Auth; | ||
|
||
internal class NoAuth : IAuth { } | ||
internal record NoAuth : IAuth; |
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,10 @@ | ||
namespace SurrealDb.Internals.Constants; | ||
|
||
internal static class HttpConstants | ||
{ | ||
public const string ACCEPT_HEADER_NAME = "Accept"; | ||
public const string NS_HEADER_NAME = "NS"; | ||
public const string DB_HEADER_NAME = "DB"; | ||
|
||
public static readonly string[] ACCEPT_HEADER_VALUES = new[] { "application/json" }; | ||
} |
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,5 @@ | ||
using SurrealDb.Internals.Auth; | ||
|
||
namespace SurrealDb.Internals.Http; | ||
|
||
internal record HttpClientConfiguration(string? Namespace, string? Database, IAuth Auth); |
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,20 @@ | ||
namespace SurrealDb.Internals.Http; | ||
|
||
internal class HttpClientWrapper : IDisposable | ||
{ | ||
private readonly bool _shouldDispose; | ||
|
||
public HttpClient Instance { get; } | ||
|
||
public HttpClientWrapper(HttpClient httpClient, bool shouldDispose) | ||
{ | ||
Instance = httpClient; | ||
_shouldDispose = shouldDispose; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (_shouldDispose) | ||
Instance.Dispose(); | ||
} | ||
} |
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 SurrealDb.Internals.Http; | ||
|
||
internal class UseConfiguration | ||
{ | ||
public string? Ns { get; set; } | ||
public string? Db { get; set; } | ||
} |
Oops, something went wrong.