-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to GenHTTP 9.6 and switch to basic handler (#8190)
* Update to GenHTTP 9.6 and switch to basic handler * Switch package references to wildcard on bugfix level Co-authored-by: Marwan Rabbâa <[email protected]> --------- Co-authored-by: Marwan Rabbâa <[email protected]>
- Loading branch information
1 parent
0b74478
commit 484339a
Showing
4 changed files
with
56 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using GenHTTP.Api.Content; | ||
using GenHTTP.Api.Protocol; | ||
|
||
using Strings = GenHTTP.Modules.IO.Strings; | ||
|
||
namespace web; | ||
|
||
internal class BenchmarkHandler : IHandler | ||
{ | ||
private static readonly FlexibleContentType _TextType = FlexibleContentType.Get(ContentType.TextPlain); | ||
|
||
private static readonly Strings.StringContent _EmptyContent = new(""); | ||
|
||
public ValueTask PrepareAsync() => new(); | ||
|
||
public ValueTask<IResponse> HandleAsync(IRequest request) | ||
{ | ||
IResponse response = null; | ||
|
||
var target = request.Target; | ||
|
||
if (target.Ended) | ||
{ | ||
response = GetEmptyResponse(request); | ||
} | ||
else if (target.Current.Original == "user") | ||
{ | ||
target.Advance(); | ||
|
||
if (target.Ended) | ||
{ | ||
response = GetEmptyResponse(request); | ||
} | ||
else | ||
{ | ||
response = GetEmptyResponse(request, new Strings.StringContent(target.Current.Original)); | ||
} | ||
} | ||
|
||
return new(response); | ||
} | ||
|
||
private static IResponse GetEmptyResponse(IRequest request, Strings.StringContent content = null) | ||
{ | ||
return request.Respond() | ||
.Type(_TextType) | ||
.Content(content ?? _EmptyContent) | ||
.Build(); | ||
} | ||
|
||
} |
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,3 +1,3 @@ | ||
framework: | ||
github: Kaliumhexacyanoferrat/GenHTTP | ||
version: 9.4 | ||
version: 9.6 |
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