Skip to content

Commit

Permalink
Merge pull request #40 from simongdavies/dynamic-route-update
Browse files Browse the repository at this point in the history
Dynamic route update
  • Loading branch information
simongdavies authored Jul 26, 2021
2 parents 038f881 + 488e009 commit 4faddce
Show file tree
Hide file tree
Showing 61 changed files with 968 additions and 423 deletions.
10 changes: 5 additions & 5 deletions examples/bindlesource/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Using Bindle to serve WAGI Modules

This example shows how to use [Bindle](https://github.com/deislabs/bindle) to host Wagi modules and serve them in wagi-dotnet.
This example shows how to serve WASM WAGI mdoules hosted in [Bindle](https://github.com/deislabs/bindle) from wagi-dotnet.

The example is configured to load three bindles from a bindle server located at `https://bindle.deislabs.io/v1`. Each bindle contains a single WASM module with a single hello world type function.
The example is configured to load three bindles from a bindle server located at `https://bindle.deislabs.io/v1`. Each bindle contains a single WASM WAGI module with a single hello world type function.

Clone the repo, switch to the examples/bindlesource folder and then run:

Expand Down Expand Up @@ -85,9 +85,9 @@ The configuration for this example can be found in the [appsettings.Development.
Example Configuration file:

``` json
// The name of the configuration section for the WASM route handler, by default this is expected to be called WASM.
"WASM": {
// The relative path to the directory where WASM modules defined in this configuration section are to be downloaded to.
// The name of the configuration section for the WAGI route handler, by default this is expected to be called Wagi.
"Wagi": {
// The relative path to the directory where WAGI modules defined in this configuration section are to be downloaded to.
"ModulePath": "modules",
// The path to a bindle server containing the bindle definitions.
"BindleServer" : "https://bindle.deislabs.io/v1",
Expand Down
25 changes: 12 additions & 13 deletions examples/bindlesource/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Deislabs.WAGI.Extensions;
using Microsoft.AspNetCore.Authentication.Cookies;
using Deislabs.Wagi.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace BindleSource
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie();
services.AddAuthorization();
services.AddHttpClient();
services.AddWagi(Configuration);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -33,11 +34,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapWASMModules();
endpoints.MapWagiModules();
});
}
}
Expand Down
14 changes: 7 additions & 7 deletions examples/bindlesource/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
"Deislabs.WAGI": "Trace"
}
},
"WASM": {
"Wagi": {
"ModulePath": "modules",
"BindleServer" : "https://bindle.deislabs.io/v1",
"BindleServer": "https://bindle.deislabs.io/v1",
"Bindles": {
"Current": {
"Name": "hippos.rocks/helloworld/1.0.0",
"Route" : "/"
"Route": "/"
},
"Version 1.1.0": {
"Name": "hippos.rocks/helloworld/1.1.0",
"Route" : "/1.1.0",
"Hostnames" : [
"Route": "/1.1.0",
"Hostnames": [
"127.0.0.1:5004",
"127.0.0.1:5005"
]
},
"Version v1": {
"Name": "hippos.rocks/helloworld/1.1.0",
"Route" : "/v1",
"Hostnames" : [
"Route": "/v1",
"Hostnames": [
"127.0.0.1:5003"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/fibonacci.test/FibonacciTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public FibonacciTest()
factory = new WebApplicationFactory<Startup>();
}
[Fact]
public async Task TestInvokeWASM()
public async Task TestInvokeWagi()
{
var client = factory.CreateClient();

Expand Down
6 changes: 3 additions & 3 deletions examples/fibonacci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ fib(93)=12200160415121876738
The configuration for this is example can be found in the [appsettings.Development.json](appsettings.Development.json) configuration file:

``` json
// The name of the configuration section for the WASM route handler, by default this is expected to be called WASM.
"WASM": {
// The relative path to the directory where WASM modules defined in this configuration section are located.
// The name of the configuration section for the WAGI route handler, by default this is expected to be called Wagi.
"Wagi": {
// The relative path to the directory where WAGI modules defined in this configuration section are located.
"ModulePath": "modules",
// A dictionary of one or more modules to be exposed by the application
"Modules": {
Expand Down
14 changes: 12 additions & 2 deletions examples/fibonacci/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
using Deislabs.WAGI.Extensions;
using Deislabs.Wagi.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Fibonacci
{
public class Startup
{
public IConfiguration Configuration { get; }

public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient();
services.AddWagi(Configuration);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -26,7 +36,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseEndpoints(endpoints =>
{
endpoints.MapWASMModules();
endpoints.MapWagiModules();
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/fibonacci/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Deislabs.WAGI": "Trace"
}
},
"WASM": {
"Wagi": {
"ModulePath": "modules",
"Modules": {
"fibonacci": {
Expand Down
6 changes: 3 additions & 3 deletions examples/simplehttp.test/SimpleHttpTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Json;
Expand Down Expand Up @@ -28,7 +28,7 @@ public SimplehttpTestFixture()
this.AccountKey = Environment.GetEnvironmentVariable(SimplehttpTestFixture.TestStorageAccountKeyEnvVar);
// TODO: create the container if not existing
this.ContainerName = "wagitest";
this.TestPostData = "Hello from wagi-experimental-http";
this.TestPostData = "Hello from wasi-experimental-http";

}
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public async Task TestReadWriteBlob()
{
var configData = $@"
{{
""WASM"": {{
""Wagi"": {{
""Modules"": {{
""Write blob"": {{
""Environment"" :{{
Expand Down
6 changes: 3 additions & 3 deletions examples/simplehttp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The Azure blob example requires an [Azure account] (https://azure.microsoft.com/
To create blobs in the Azure Storage service configure the WAGI Modules with details of the [Azure Storage Account](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal) to read and write to, modify [appsettings.Development.json](appsettings.Development.json) as follows:

```
"WASM": {
"Wagi": {
"ModulePath": "modules",
"Modules": {
"Write blob": {
Expand All @@ -58,7 +58,7 @@ To create blobs in the Azure Storage service configure the WAGI Modules with det
"STORAGE_MASTER_KEY" : "" // STORAGE_MASTER_KEY should be set to one of the Azure storage account keys
},
"AllowedHosts": [
"https://<storage_account>.blob.core.windows.net" // replace <storage_account> with the storage account name
"https://YOUR_STORAGE_ACCOUNT.blob.core.windows.net" // replace YOUR_STORAGE_ACCOUNT with the storage account name
],
"HttpMethod": "post",
"Route" : "/writeblob"
Expand All @@ -71,7 +71,7 @@ To create blobs in the Azure Storage service configure the WAGI Modules with det
"STORAGE_MASTER_KEY" : "" // STORAGE_MASTER_KEY should be set to one of the Azure storage account keys
},
"AllowedHosts": [
"https://<storage_account>.blob.core.windows.net" // replace <storage_account> with the storage
"https://YOUR_STORAGE_ACCOUNT.blob.core.windows.net" // replace YOUR_STORAGE_ACCOUNT with the storage
],
"Route" : "/readblob"
}
Expand Down
19 changes: 11 additions & 8 deletions examples/simplehttp/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Deislabs.WAGI.Extensions;
using Microsoft.AspNetCore.Authentication.Cookies;
using Deislabs.Wagi.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Simplehttp
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient();
services.AddWagi(Configuration);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -33,7 +36,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseEndpoints(endpoints =>
{
endpoints.MapWASMModules();
endpoints.MapWagiModules();
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/simplehttp/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"Wasi.Experimental.Http": "Trace"
}
},
"WASM": {
"Wagi": {
"ModulePath": "modules",
"Modules": {
"Simple Test": {
Expand All @@ -30,7 +30,7 @@
"STORAGE_MASTER_KEY" : ""
},
"AllowedHosts": [
"https://<storage_account>.blob.core.windows.net"
"https://YOUR_STORAGE_ACCOUNT.blob.core.windows.net"
],
"HttpMethod": "post",
"Route": "/writeblob"
Expand All @@ -43,7 +43,7 @@
"STORAGE_MASTER_KEY" : ""
},
"AllowedHosts": [
"https://<storage_account>.blob.core.windows.net"
"https://YOUR_STORAGE_ACCOUNT.blob.core.windows.net"
],
"Route": "/readblob"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/watm.test/WatmTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public WatmTest()
factory = new WebApplicationFactory<Startup>();
}
[Fact]
public async Task TestInvokeWASM()
public async Task TestInvokeWagi()
{
var client = factory.CreateClient();

Expand Down
6 changes: 3 additions & 3 deletions examples/watm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Hello World!
The configuration for this is example can be found in the [appsettings.Development.json](appsettings.Development.json) configuration file:

``` json
// The name of the configuration section for the WASM route handler, by default this is expected to be called WASM.
"WASM": {
// The relative path to the directory where WASM modules defined in this configuration section are located.
// The name of the configuration section for the WAGI route handler, by default this is expected to be called Wagi.
"Wagi": {
// The relative path to the directory where WAGI modules defined in this configuration section are located.
"ModulePath": "modules",
// A dictionary of one or more modules to be exposed by the application
"Modules": {
Expand Down
25 changes: 12 additions & 13 deletions examples/watm/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Deislabs.WAGI.Extensions;
using Microsoft.AspNetCore.Authentication.Cookies;
using Deislabs.Wagi.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Watm
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie();
services.AddAuthorization();
services.AddHttpClient();
services.AddWagi(Configuration);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -33,11 +34,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapWASMModules();
endpoints.MapWagiModules();
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/watm/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Deislabs.WAGI": "Trace"
}
},
"WASM": {
"Wagi": {
"ModulePath": "modules",
"Modules": {
"hellowat": {
Expand Down
2 changes: 1 addition & 1 deletion examples/watmwithauth/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"watm": {
"watmwithauth": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
Expand Down
Loading

0 comments on commit 4faddce

Please sign in to comment.