diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 85237fc..461a6d2 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - dir: [consent-management, data-collection] + dir: [edge-function, data-collection] defaults: run: working-directory: ${{ matrix.dir }} diff --git a/consent-management/Component.cs b/consent-management/Component.cs deleted file mode 100644 index f5710ca..0000000 --- a/consent-management/Component.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace ConsentManagementWorld.wit.exports.edgee.components.v1_0_0; - -public struct Settings { - public string Example { get; } - - public Settings(List<(string, string)> settings) { - Example = string.Empty; - foreach (var setting in settings) { - if (setting.Item1 == "example") { - Example = setting.Item2; - } - } - } -} - -public struct Cookies { - public string Example { get; } - - public Cookies(List<(string, string)> cookies) { - Example = string.Empty; - foreach (var cookie in cookies) { - if (cookie.Item1 == "example") { - Example = cookie.Item2; - } - } - } -} - -public class ConsentManagementImpl: IConsentManagement { - public static IConsentManagement.Consent? Map(List<(string, string)> cookies, List<(string, string)> settings) { - Settings s = new Settings(settings); - Cookies c = new Cookies(cookies); - - if (c.Example == string.Empty) { - return null; - } else if (c.Example == "granted") { - return IConsentManagement.Consent.GRANTED; - } else if (c.Example == "denied") { - return IConsentManagement.Consent.DENIED; - } else { - return IConsentManagement.Consent.PENDING; - } - - } -} - diff --git a/consent-management/.gitignore b/edge-function/.gitignore similarity index 100% rename from consent-management/.gitignore rename to edge-function/.gitignore diff --git a/edge-function/Component.cs b/edge-function/Component.cs new file mode 100644 index 0000000..d98f189 --- /dev/null +++ b/edge-function/Component.cs @@ -0,0 +1,30 @@ +namespace EdgeFunctionWorld.wit.exports.wasi.http.v0_2_0; +using System.Text; + +using EdgeFunctionWorld; +using EdgeFunctionWorld.wit.exports.wasi.http.v0_2_0; +using EdgeFunctionWorld.wit.imports.wasi.http.v0_2_0; +using EdgeFunctionWorld.wit.imports.wasi.io.v0_2_0; + +public class IncomingHandlerImpl: IIncomingHandler { + public static void Handle(ITypes.IncomingRequest request, ITypes.ResponseOutparam responseOut) { + byte[] content = "Hello, World!"u8.ToArray(); + List<(string, byte[])> headers = + [ + ("content-type", "text/plain"u8.ToArray()), + ("content-length", Encoding.ASCII.GetBytes(content.Length.ToString())) + ]; + + ITypes.OutgoingResponse response = new(ITypes.Fields.FromList(headers)); + ITypes.OutgoingBody body = response.Body(); + + ITypes.ResponseOutparam.Set(responseOut, Result.Ok(response)); + + using IStreams.OutputStream stream = body.Write(); + stream.BlockingWriteAndFlush(content); + stream.Dispose(); + + ITypes.OutgoingBody.Finish(body, null); + } +} + diff --git a/consent-management/Makefile b/edge-function/Makefile similarity index 100% rename from consent-management/Makefile rename to edge-function/Makefile diff --git a/consent-management/README.md b/edge-function/README.md similarity index 100% rename from consent-management/README.md rename to edge-function/README.md diff --git a/consent-management/edgee-component.toml b/edge-function/edgee-component.toml similarity index 72% rename from consent-management/edgee-component.toml rename to edge-function/edgee-component.toml index 6ce57b0..6d461ad 100644 --- a/consent-management/edgee-component.toml +++ b/edge-function/edgee-component.toml @@ -1,11 +1,11 @@ manifest-version = 1 [component] -name = "example-cs-consent-management-component" +name = "example-cs-edge-function-component" version = "1.0.0" -category = "consent-management" -subcategory = "consent-mapping" -description = "Example CSharp component for consent management" +category = "edge-function" +subcategory = "wasm-function" +description = "Example CSharp component for edge-function" documentation = "https://github.com/edgee-cloud/example-cs-component" repository = "https://github.com/edgee-cloud/example-cs-component" language = "CSharp" diff --git a/consent-management/example-cs-component.csproj b/edge-function/example-cs-component.csproj similarity index 93% rename from consent-management/example-cs-component.csproj rename to edge-function/example-cs-component.csproj index 1446b3b..6115c23 100644 --- a/consent-management/example-cs-component.csproj +++ b/edge-function/example-cs-component.csproj @@ -20,7 +20,7 @@ - + diff --git a/consent-management/nuget.config b/edge-function/nuget.config similarity index 100% rename from consent-management/nuget.config rename to edge-function/nuget.config