Skip to content

Commit 27f8f25

Browse files
committed
Change SelfHost test to use S3 VirtualFiles
1 parent ec7a967 commit 27f8f25

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

lib/net45/ServiceStack.Aws.dll

512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
152 Bytes
Binary file not shown.

src/ServiceStack.Core.SelfHost/ServiceStack.Core.SelfHost.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
15+
<PackageReference Include="AWSSDK.S3" Version="3.3.*" />
16+
<PackageReference Include="AWSSDK.Core" Version="3.3.*" />
1517
<Reference Include="..\..\lib\netstandard1.1\ServiceStack.Interfaces.dll" />
1618
<Reference Include="..\..\lib\netstandard1.3\ServiceStack.Text.dll" />
17-
<ProjectReference Include="..\ServiceStack\ServiceStack.csproj" />
19+
20+
<!-- <Reference Include="..\..\lib\netstandard1.6\ServiceStack.Aws.dll" /> -->
21+
<ProjectReference Include="..\..\..\ServiceStack.Aws\src\ServiceStack.Aws\ServiceStack.Aws.csproj" />
22+
1823
<ProjectReference Include="..\ServiceStack.Client\ServiceStack.Client.csproj" />
1924
<ProjectReference Include="..\ServiceStack.Common\ServiceStack.Common.csproj" />
25+
<ProjectReference Include="..\ServiceStack\ServiceStack.csproj" />
26+
<ProjectReference Include="..\ServiceStack.Server\ServiceStack.Server.csproj" />
2027
<ProjectReference Include="..\ServiceStack.Api.Swagger\ServiceStack.Api.Swagger.csproj" />
2128
</ItemGroup>
2229

src/ServiceStack.Core.SelfHost/Startup.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
using ServiceStack.Api.Swagger;
1717
using ServiceStack.Metadata;
1818
using ServiceStack.Web;
19+
using ServiceStack.IO;
20+
using ServiceStack.Aws.S3;
21+
using Amazon;
22+
using Amazon.S3;
1923

2024
namespace ServiceStack.Core.SelfHost
2125
{
@@ -30,13 +34,16 @@ public void ConfigureServices(IServiceCollection services)
3034
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3135
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
3236
{
33-
app.UseDeveloperExceptionPage();
37+
app.Use(async (context, next) => {
38+
Console.WriteLine(context.Request.Path.Value);
39+
await next();
40+
});
3441

3542
app.UseServiceStack(new AppHost());
3643

3744
app.Run(async (context) =>
3845
{
39-
await context.Response.WriteAsync("Hello World!");
46+
await context.Response.WriteAsync("Unhandled Request!");
4047
});
4148
}
4249
}
@@ -116,8 +123,23 @@ public AppHost()
116123

117124
public override void Configure(Container container)
118125
{
126+
var s3Client = new AmazonS3Client(
127+
Environment.GetEnvironmentVariable("S3_ACCESS_KEY"),
128+
Environment.GetEnvironmentVariable("S3_SECRET_KEY"),
129+
RegionEndpoint.USEast1);
130+
131+
VirtualFiles = new S3VirtualFiles(s3Client, "s3-postgresql");
132+
133+
Plugins.Add(new TemplatePagesFeature());
119134
Plugins.Add(new SwaggerFeature());
120135
}
136+
public override List<IVirtualPathProvider> GetVirtualFileSources()
137+
{
138+
var fileSources = base.GetVirtualFileSources();
139+
fileSources.Add(VirtualFiles);
140+
return fileSources;
141+
}
142+
121143
}
122144

123145
}

0 commit comments

Comments
 (0)