-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove deprecated templates, add new controller-service
- Loading branch information
1 parent
72ef2bf
commit 0166da9
Showing
78 changed files
with
283 additions
and
1,795 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
26 changes: 26 additions & 0 deletions
26
Templates/Webservice-Controllers/$safeprojectname$/$safeprojectname$.csproj
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,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
|
||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
|
||
<Nullable>enable</Nullable> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
|
||
<AssemblyVersion>0.1.0.0</AssemblyVersion> | ||
<FileVersion>0.1.0.0</FileVersion> | ||
<Version>0.1.0</Version> | ||
|
||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
|
||
<PackageReference Include="GenHTTP.Core" Version="8.5.2" /> | ||
|
||
<PackageReference Include="GenHTTP.Modules.Security" Version="8.5.0" /> | ||
<PackageReference Include="GenHTTP.Modules.Controllers" Version="8.5.0" /> | ||
|
||
</ItemGroup> | ||
|
||
</Project> |
53 changes: 53 additions & 0 deletions
53
Templates/Webservice-Controllers/$safeprojectname$/Controllers/DeviceController.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,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using GenHTTP.Api.Protocol; | ||
|
||
using GenHTTP.Modules.Controllers; | ||
|
||
using $safeprojectname$.Model; | ||
|
||
namespace $safeprojectname$.Controllers | ||
{ | ||
|
||
// For documentation, see: https://genhttp.org/documentation/content/frameworks/controllers/ | ||
|
||
public class DeviceController | ||
{ | ||
|
||
public List<DeviceSummary> Index() | ||
{ | ||
// GET http://localhost:8080/devices/ | ||
return [new(Guid.NewGuid(), "Some Device")]; | ||
} | ||
|
||
public DeviceDetails? Index([FromPath] Guid id) | ||
{ | ||
// GET http://localhost:8080/devices/:id/ | ||
return new(id, "Some Device", "127.0.0.1"); | ||
} | ||
|
||
[ControllerAction(RequestMethod.PUT)] | ||
public Guid Add(DeviceDetails device) | ||
{ | ||
// PUT http://localhost:8080/devices/add/ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
[ControllerAction(RequestMethod.POST)] | ||
public Guid? Update(DeviceDetails book) | ||
{ | ||
// POST http://localhost:8080/devices/update/ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
[ControllerAction(RequestMethod.DELETE)] | ||
public Guid? Remove([FromPath] Guid id) | ||
{ | ||
// DELETE http://localhost:8080/devices/remove/:id/ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
Templates/Webservice-Controllers/$safeprojectname$/Model/Device.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,10 @@ | ||
using System; | ||
|
||
namespace $safeprojectname$.Model | ||
{ | ||
|
||
public record DeviceSummary(Guid ID, string Name); | ||
|
||
public record DeviceDetails(Guid ID, string Name, string Address); | ||
|
||
} |
34 changes: 17 additions & 17 deletions
34
...ates/Website/$safeprojectname$/Program.cs → ...-Controllers/$safeprojectname$/Program.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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
using GenHTTP.Engine; | ||
|
||
using GenHTTP.Modules.Practices; | ||
|
||
using $safeprojectname$; | ||
|
||
var project = Project.Create(); | ||
|
||
return Host.Create() | ||
.Handler(project) | ||
.Defaults() | ||
.Console() | ||
//-:cnd:noEmit | ||
#if DEBUG | ||
.Development() | ||
#endif | ||
//+:cnd:noEmit | ||
using GenHTTP.Engine; | ||
|
||
using GenHTTP.Modules.Practices; | ||
|
||
using $safeprojectname$; | ||
|
||
var project = Project.Setup(); | ||
|
||
return Host.Create() | ||
.Handler(project) | ||
.Defaults() | ||
.Console() | ||
//-:cnd:noEmit | ||
#if DEBUG | ||
.Development() | ||
#endif | ||
//+:cnd:noEmit | ||
.Run(); |
24 changes: 24 additions & 0 deletions
24
Templates/Webservice-Controllers/$safeprojectname$/Project.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 GenHTTP.Api.Content; | ||
|
||
using GenHTTP.Modules.Layouting; | ||
using GenHTTP.Modules.Security; | ||
using GenHTTP.Modules.Controllers; | ||
|
||
using $safeprojectname$.Controllers; | ||
|
||
namespace $safeprojectname$ | ||
{ | ||
|
||
public static class Project | ||
{ | ||
|
||
public static IHandlerBuilder Setup() | ||
{ | ||
return Layout.Create() | ||
.AddController<DeviceController>("devices") | ||
.Add(CorsPolicy.Permissive()); | ||
} | ||
|
||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
Templates/Webservice-Controllers/.template.config/template.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,22 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Andreas Nägeli", | ||
"classifications": [ "GenHTTP", "Webservices", "REST", "Web API", "Controllers" ], | ||
"identity": "GenHTTP.Templates.Webservice.Controllers", | ||
"name": "GenHTTP: Webservice (Controllers)", | ||
"shortName": "genhttp-webservice-controllers", | ||
"sourceName": "$safeprojectname$", | ||
"description": "A project template to host a REST webservice by utilizing controllers using the GenHTTP webserver", | ||
"tags": { | ||
"language": "C#", | ||
"type": "project" | ||
}, | ||
"primaryOutputs": [ | ||
{ | ||
"path": "$safeprojectname$\\$safeprojectname$.csproj" | ||
}, | ||
{ | ||
"path": "$safeprojectname$.Tests\\$safeprojectname$.Tests.csproj" | ||
} | ||
] | ||
} |
38 changes: 19 additions & 19 deletions
38
Templates/Website/Dockerfile.linux-arm32 → ...ervice-Controllers/Dockerfile.linux-arm32
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,19 +1,19 @@ | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
WORKDIR /source | ||
# copy csproj and restore as distinct layers | ||
COPY $safeprojectname$/*.csproj . | ||
RUN dotnet restore -r linux-arm | ||
# copy and publish app and libraries | ||
COPY $safeprojectname$/ . | ||
RUN dotnet publish -c release -o /app -r linux-arm --no-restore /p:PublishTrimmed=true /p:TrimMode=Link | ||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-arm32v7 | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
ENTRYPOINT ["./$safeprojectname$"] | ||
EXPOSE 8080 | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY $safeprojectname$/*.csproj . | ||
RUN dotnet restore -r linux-arm | ||
|
||
# copy and publish app and libraries | ||
COPY $safeprojectname$/ . | ||
RUN dotnet publish -c release -o /app -r linux-arm --no-restore /p:PublishTrimmed=true /p:TrimMode=Link | ||
|
||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-arm32v7 | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
|
||
ENTRYPOINT ["./$safeprojectname$"] | ||
|
||
EXPOSE 8080 |
38 changes: 19 additions & 19 deletions
38
.../Website-MVC-Razor/Dockerfile.linux-arm64 → ...ervice-Controllers/Dockerfile.linux-arm64
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,19 +1,19 @@ | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
WORKDIR /source | ||
# copy csproj and restore as distinct layers | ||
COPY $safeprojectname$/*.csproj . | ||
RUN dotnet restore -r linux-arm64 | ||
# copy and publish app and libraries | ||
COPY $safeprojectname$/ . | ||
RUN dotnet publish -c release -o /app -r linux-arm64 --no-restore /p:PublishTrimmed=true /p:TrimMode=Link | ||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-arm64v8 | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
ENTRYPOINT ["./$safeprojectname$"] | ||
EXPOSE 8080 | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY $safeprojectname$/*.csproj . | ||
RUN dotnet restore -r linux-arm64 | ||
|
||
# copy and publish app and libraries | ||
COPY $safeprojectname$/ . | ||
RUN dotnet publish -c release -o /app -r linux-arm64 --no-restore /p:PublishTrimmed=true /p:TrimMode=Link | ||
|
||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-arm64v8 | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
|
||
ENTRYPOINT ["./$safeprojectname$"] | ||
|
||
EXPOSE 8080 |
38 changes: 19 additions & 19 deletions
38
.../Website-MVC-Scriban/Dockerfile.linux-x64 → ...bservice-Controllers/Dockerfile.linux-x64
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,19 +1,19 @@ | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build | ||
WORKDIR /source | ||
# copy csproj and restore as distinct layers | ||
COPY $safeprojectname$/*.csproj . | ||
RUN dotnet restore -r linux-musl-x64 | ||
# copy and publish app and libraries | ||
COPY $safeprojectname$/ . | ||
RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore /p:PublishTrimmed=true /p:TrimMode=Link | ||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
ENTRYPOINT ["./$safeprojectname$"] | ||
EXPOSE 8080 | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY $safeprojectname$/*.csproj . | ||
RUN dotnet restore -r linux-musl-x64 | ||
|
||
# copy and publish app and libraries | ||
COPY $safeprojectname$/ . | ||
RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore /p:PublishTrimmed=true /p:TrimMode=Link | ||
|
||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
|
||
ENTRYPOINT ["./$safeprojectname$"] | ||
|
||
EXPOSE 8080 |
Oops, something went wrong.