-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] request handling pipeline with handlers
- Loading branch information
Showing
11 changed files
with
94 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Threading.Tasks; | ||
using Simplify.Web.Core2.Http; | ||
|
||
namespace Simplify.Web.Core2.PageComposition; | ||
|
||
/// <summary> | ||
/// Represent web-page processor. | ||
/// </summary> | ||
public interface IPageRenderer | ||
{ | ||
/// <summary> | ||
/// Processes (build web-page and send to client, process current page state) the current web-page. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
Task Render(IHttpContext context); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Simplify.Web/Core2/RequestHandling/Handlers/PageRenderingHandler.cs
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,14 @@ | ||
using System.Threading.Tasks; | ||
using Simplify.Web.Core2.Http; | ||
using Simplify.Web.Core2.PageComposition; | ||
|
||
namespace Simplify.Web.Core2.RequestHandling.Handlers; | ||
|
||
public class PageRenderingHandler(IPageRenderer renderer) : IRequestHandler | ||
Check warning on line 7 in src/Simplify.Web/Core2/RequestHandling/Handlers/PageRenderingHandler.cs
|
||
{ | ||
public async Task Execute(IHttpContext context, RequestHandler next) | ||
Check warning on line 9 in src/Simplify.Web/Core2/RequestHandling/Handlers/PageRenderingHandler.cs
|
||
{ | ||
await renderer.Render(context); | ||
await next(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Simplify.Web/Core2/RequestHandling/Handlers/StaticFilesHandler.cs
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,16 @@ | ||
using System.Threading.Tasks; | ||
using Simplify.Web.Core2.Http; | ||
using Simplify.Web.Core2.StaticFiles; | ||
|
||
namespace Simplify.Web.Core2.RequestHandling.Handlers; | ||
|
||
public class StaticFilesHandler(IStaticFileRequestHandler handler) : IRequestHandler | ||
{ | ||
public async Task Execute(IHttpContext context, RequestHandler next) | ||
{ | ||
if (handler.IsStaticFileRoutePath(context)) | ||
await handler.Execute(context); | ||
else | ||
await next(); | ||
} | ||
} |
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,9 @@ | ||
using System.Threading.Tasks; | ||
using Simplify.Web.Core2.Http; | ||
|
||
namespace Simplify.Web.Core2.RequestHandling; | ||
|
||
public interface IRequestHandler | ||
{ | ||
Task Execute(IHttpContext context, RequestHandler next); | ||
} |
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,5 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Simplify.Web.Core2.RequestHandling; | ||
|
||
public delegate Task RequestHandler(); |
This file was deleted.
Oops, something went wrong.
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
24 changes: 24 additions & 0 deletions
24
src/Simplify.Web/Core2/StaticFiles/IStaticFileRequestHandler.cs
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,24 @@ | ||
using System.Threading.Tasks; | ||
using Simplify.Web.Core2.Http; | ||
|
||
namespace Simplify.Web.Core2.StaticFiles; | ||
|
||
/// <summary> | ||
/// Represent static files request handler. | ||
/// </summary> | ||
public interface IStaticFileRequestHandler | ||
{ | ||
/// <summary> | ||
/// Determines whether current route path is for static file. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <returns></returns> | ||
bool IsStaticFileRoutePath(IHttpContext context); | ||
|
||
/// <summary> | ||
/// Processes the HTTP request for static files. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <returns></returns> | ||
Task Execute(IHttpContext context); | ||
} |
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