Skip to content

Commit 146b685

Browse files
Edge function: first implem (#12)
* remove consent management * edge-function: wip * CI: build edge-function * fixup! edge-function: wip
1 parent d6f29b7 commit 146b685

File tree

9 files changed

+36
-52
lines changed

9 files changed

+36
-52
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
dir: [consent-management, data-collection]
17+
dir: [edge-function, data-collection]
1818
defaults:
1919
run:
2020
working-directory: ${{ matrix.dir }}

consent-management/Component.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.
File renamed without changes.

edge-function/Component.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace EdgeFunctionWorld.wit.exports.wasi.http.v0_2_0;
2+
using System.Text;
3+
4+
using EdgeFunctionWorld;
5+
using EdgeFunctionWorld.wit.exports.wasi.http.v0_2_0;
6+
using EdgeFunctionWorld.wit.imports.wasi.http.v0_2_0;
7+
using EdgeFunctionWorld.wit.imports.wasi.io.v0_2_0;
8+
9+
public class IncomingHandlerImpl: IIncomingHandler {
10+
public static void Handle(ITypes.IncomingRequest request, ITypes.ResponseOutparam responseOut) {
11+
byte[] content = "Hello, World!"u8.ToArray();
12+
List<(string, byte[])> headers =
13+
[
14+
("content-type", "text/plain"u8.ToArray()),
15+
("content-length", Encoding.ASCII.GetBytes(content.Length.ToString()))
16+
];
17+
18+
ITypes.OutgoingResponse response = new(ITypes.Fields.FromList(headers));
19+
ITypes.OutgoingBody body = response.Body();
20+
21+
ITypes.ResponseOutparam.Set(responseOut, Result<ITypes.OutgoingResponse, ITypes.ErrorCode>.Ok(response));
22+
23+
using IStreams.OutputStream stream = body.Write();
24+
stream.BlockingWriteAndFlush(content);
25+
stream.Dispose();
26+
27+
ITypes.OutgoingBody.Finish(body, null);
28+
}
29+
}
30+
File renamed without changes.
File renamed without changes.

consent-management/edgee-component.toml renamed to edge-function/edgee-component.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
manifest-version = 1
22

33
[component]
4-
name = "example-cs-consent-management-component"
4+
name = "example-cs-edge-function-component"
55
version = "1.0.0"
6-
category = "consent-management"
7-
subcategory = "consent-mapping"
8-
description = "Example CSharp component for consent management"
6+
category = "edge-function"
7+
subcategory = "wasm-function"
8+
description = "Example CSharp component for edge-function"
99
documentation = "https://github.com/edgee-cloud/example-cs-component"
1010
repository = "https://github.com/edgee-cloud/example-cs-component"
1111
language = "CSharp"

consent-management/example-cs-component.csproj renamed to edge-function/example-cs-component.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<ItemGroup>
2222
<Wit Remove="**\*.wit" />
23-
<Wit Include=".edgee/wit" World="consent-management" />
23+
<Wit Include=".edgee/wit" World="edge-function" />
2424
</ItemGroup>
2525

2626
</Project>
File renamed without changes.

0 commit comments

Comments
 (0)