-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
45 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
using Funq; | ||
using ServiceStack; | ||
using MyApp.ServiceInterface; | ||
|
||
[assembly: HostingStartup(typeof(MyApp.AppHost))] | ||
[assembly: HostingStartup(typeof(MyApp.AppHost))] | ||
|
||
namespace MyApp; | ||
|
||
public class AppHost : AppHostBase, IHostingStartup | ||
public class AppHost() : AppHostBase("MyApp"), IHostingStartup | ||
{ | ||
public void Configure(IWebHostBuilder builder) => builder | ||
.ConfigureServices(services => { | ||
// Configure ASP.NET Core IOC Dependencies | ||
}); | ||
|
||
public AppHost() : base("MyApp", typeof(MyServices).Assembly) {} | ||
|
||
public override void Configure(Container container) | ||
public override void Configure() | ||
{ | ||
// Configure ServiceStack only IOC, Config & Plugins | ||
// Configure ServiceStack, Run custom logic after ASP.NET Core Startup | ||
SetConfig(new HostConfig { | ||
UseSameSiteCookies = true, | ||
}); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
var builder = WebApplication.CreateBuilder(args); | ||
using MyApp.ServiceInterface; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
var services = builder.Services; | ||
|
||
services.AddServiceStack(typeof(MyServices).Assembly, c => | ||
{ | ||
c.AddSwagger(); | ||
}); | ||
|
||
services.AddEndpointsApiExplorer(); | ||
services.AddSwaggerGen(); | ||
|
||
var app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (!app.Environment.IsDevelopment()) | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseExceptionHandler("/Error"); | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
} | ||
else | ||
{ | ||
app.UseExceptionHandler("/Error", createScopeForErrors: true); | ||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | ||
app.UseHsts(); | ||
app.UseHttpsRedirection(); | ||
} | ||
app.UseServiceStack(new AppHost()); | ||
|
||
app.UseStaticFiles(); | ||
|
||
app.UseServiceStack(new AppHost(), options => { | ||
options.MapEndpoints(); | ||
}); | ||
|
||
app.Run(); |
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
h2, h3, strong { font-weight:500 } | ||
</style> | ||
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/[email protected]/styles/atom-one-dark.min.css"> | ||
<script async src="https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js"></script><!--safari polyfill--> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
|
@@ -28,10 +27,10 @@ <h2><a href="/ui/Hello">Hello</a> API</h2> | |
<div id="result"></div> | ||
|
||
<script type="module"> | ||
import { JsonApiClient, $1, on } from '@servicestack/client' | ||
import { JsonServiceClient, $1, on } from '@servicestack/client' | ||
import { Hello } from '/types/mjs' | ||
|
||
const client = JsonApiClient.create() | ||
const client = new JsonServiceClient() | ||
on('#txtName', { | ||
/** @param {Event} el */ | ||
async keyup(el) { | ||
|
@@ -53,6 +52,10 @@ <h2><a href="/ui/Hello">Hello</a> API</h2> | |
- [View API Details](/ui/Hello?tab=details) | ||
- [Browse API source code in different langauges](/ui/Hello?tab=code) | ||
|
||
## View in Swagger UI | ||
- [Swagger UI](/swagger/index.html) | ||
- [Open API v3 JSON](/swagger/v1/swagger.json) | ||
|
||
### Using JsonServiceClient in Web Pages | ||
|
||
Easiest way to call APIs is to use [@servicestack/client](https://docs.servicestack.net/javascript-client) with | ||
|
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