aboutsummaryrefslogtreecommitdiffstats
path: root/code/lib
diff options
context:
space:
mode:
Diffstat (limited to 'code/lib')
-rw-r--r--code/lib/AsyncEndpoint.cs40
-rw-r--r--code/lib/I2R.Endpoints.csproj30
-rw-r--r--code/lib/SyncEndpoint.cs34
3 files changed, 104 insertions, 0 deletions
diff --git a/code/lib/AsyncEndpoint.cs b/code/lib/AsyncEndpoint.cs
new file mode 100644
index 0000000..505032c
--- /dev/null
+++ b/code/lib/AsyncEndpoint.cs
@@ -0,0 +1,40 @@
+namespace I2R.Endpoints;
+
+public static partial class AsyncEndpoint<TBaseEndpoint>
+{
+ public static class Req<TRequest>
+ {
+ public abstract class Res<TResponse>
+ {
+ public abstract Task<TResponse> HandleAsync(
+ TRequest request,
+ CancellationToken cancellationToken = default
+ );
+ }
+
+ public abstract class NoRes
+ {
+ public abstract Task HandleAsync(
+ TRequest request,
+ CancellationToken cancellationToken = default
+ );
+ }
+ }
+
+ public static class NoReq
+ {
+ public abstract class Res<TResponse>
+ {
+ public abstract Task<TResponse> HandleAsync(
+ CancellationToken cancellationToken = default
+ );
+ }
+
+ public abstract class NoRes
+ {
+ public abstract Task HandleAsync(
+ CancellationToken cancellationToken = default
+ );
+ }
+ }
+} \ No newline at end of file
diff --git a/code/lib/I2R.Endpoints.csproj b/code/lib/I2R.Endpoints.csproj
new file mode 100644
index 0000000..90ecd90
--- /dev/null
+++ b/code/lib/I2R.Endpoints.csproj
@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net7.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <PackageLicenseUrl>https://git.ivar.systems/dotnet-endpoints/tree/COPYING</PackageLicenseUrl>
+ <RepositoryUrl>https://git.ivar.systems/dotnet-endpoints</RepositoryUrl>
+ <RepositoryType>git</RepositoryType>
+ <PackageVersion>1.1.0</PackageVersion>
+ <Title>I2R.Endpoints</Title>
+ <Authors>Ivar Løvlie</Authors>
+ <Description>A library that enables single file endpoints (or whatever).</Description>
+ <Copyright>Ivar Løvlie</Copyright>
+ <PackageReleaseNotes>
+ Initial realease.
+ </PackageReleaseNotes>
+ <IsPackable>true</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\source-generator\I2R.Endpoints.Generator.csproj"
+ OutputItemType="Analyzer"
+ ReferenceOutputAssembly="false"/>
+ </ItemGroup>
+
+ <ItemGroup>
+ <AnalyzerReference Include="..\source-generator\I2R.Endpoints.Generator.csproj"/>
+ </ItemGroup>
+
+</Project>
diff --git a/code/lib/SyncEndpoint.cs b/code/lib/SyncEndpoint.cs
new file mode 100644
index 0000000..f30923a
--- /dev/null
+++ b/code/lib/SyncEndpoint.cs
@@ -0,0 +1,34 @@
+namespace I2R.Endpoints;
+
+public static partial class SyncEndpoint<TBaseEndpoint>
+{
+ public static class Req<TRequest>
+ {
+ public abstract class Res<TResponse>
+ {
+ public abstract TResponse Handle(
+ TRequest request
+ );
+ }
+
+ public abstract class NoRes
+ {
+ public abstract void Handle(
+ TRequest request
+ );
+ }
+ }
+
+ public static class NoReq
+ {
+ public abstract class Res<TResponse>
+ {
+ public abstract TResponse Handle();
+ }
+
+ public abstract class NoRes
+ {
+ public abstract void Handle();
+ }
+ }
+} \ No newline at end of file