Skip to content

Commit cec1ead

Browse files
author
Bart Koelman
committed
Merge branch 'master' into content-negotiation-tests
2 parents 6e24a80 + ccaff6d commit cec1ead

File tree

5 files changed

+37
-24
lines changed

5 files changed

+37
-24
lines changed

Diff for: docs/generate-examples.ps1

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33
# This script generates response documents for ./request-examples
44

55
function Kill-WebServer {
6-
$tcpConnections = Get-NetTCPConnection -LocalPort 14141 -ErrorAction SilentlyContinue
7-
if ($tcpConnections -ne $null) {
6+
$processId = $null
7+
if ($IsMacOs || $IsLinux) {
8+
$processId = $(lsof -ti:8080)
9+
}
10+
elseif ($IsWindows) {
11+
$processId = $(Get-NetTCPConnection -LocalPort 14141 -ErrorAction SilentlyContinue).OwningProcess
12+
}
13+
14+
if ($processId -ne $null) {
815
Write-Output "Stopping web server"
9-
Get-Process -Id $tcpConnections.OwningProcess | Stop-Process
16+
Get-Process -Id $processId | Stop-Process
1017
}
18+
1119
}
1220

1321
function Start-Webserver {

Diff for: docs/home/index.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta content="width=device-width, initial-scale=1.0" name="viewport">
6-
<title>JsonApiDotNetCore</title>
6+
<title>JSON:API .NET Core</title>
77
<meta content="" name="descriptison">
88
<meta content="" name="keywords">
99
<link href="favicon.ico" rel="icon">
@@ -213,6 +213,10 @@ <h4 class="title">Response</h4>
213213
"links": {
214214
"self": "/articles/1/relationships/author",
215215
"related": "/articles/1/author"
216+
},
217+
"data": {
218+
"type": "people",
219+
"id": "1"
216220
}
217221
}
218222
},

Diff for: docs/usage/extensibility/controllers.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public class ArticlesController : BaseJsonApiController<Article>
5151
{ }
5252

5353
[HttpGet]
54-
public override async Task<IActionResult> GetAsync()
54+
public override async Task<IActionResult> GetAsync(CancellationToken cancellationToken)
5555
{
56-
return await base.GetAsync();
56+
return await base.GetAsync(cancellationToken);
5757
}
5858

5959
[HttpGet("{id}")]
60-
public override async Task<IActionResult> GetAsync(int id)
60+
public override async Task<IActionResult> GetAsync(int id, CancellationToken cancellationToken)
6161
{
62-
return await base.GetAsync(id);
62+
return await base.GetAsync(id, cancellationToken);
6363
}
6464
}
6565
```
@@ -108,9 +108,9 @@ public class ReportsController : BaseJsonApiController<Report>
108108
{ }
109109

110110
[HttpGet]
111-
public override async Task<IActionResult> GetAsync()
111+
public override async Task<IActionResult> GetAsync(CancellationToken cancellationToken)
112112
{
113-
return await base.GetAsync();
113+
return await base.GetAsync(cancellationToken);
114114
}
115115
}
116116
```

Diff for: docs/usage/extensibility/repositories.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ public class ArticleRepository : EntityFrameworkCoreRepository<Article>
5151
_authenticationService = authenticationService;
5252
}
5353

54-
public override IQueryable<Article> GetAll()
54+
public override IQueryable<Article> GetAll(CancellationToken cancellationToken)
5555
{
56-
return base.Get().Where(article => article.UserId == _authenticationService.UserId);
56+
return base.GetAll(cancellationToken)
57+
.Where(article => article.UserId == _authenticationService.UserId);
5758
}
5859
}
5960
```

Diff for: docs/usage/extensibility/services.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ public class TodoItemService : JsonApiResourceService<TodoItem>
1616
private readonly INotificationService _notificationService;
1717

1818
public TodoItemService(
19-
IResourceRepository<TodoItem> repository,
19+
IResourceRepositoryAccessor repositoryAccessor,
2020
IQueryLayerComposer queryLayerComposer,
2121
IPaginationContext paginationContext,
2222
IJsonApiOptions options,
2323
ILoggerFactory loggerFactory,
2424
IJsonApiRequest request,
2525
IResourceChangeTracker<TodoItem> resourceChangeTracker,
2626
IResourceFactory resourceFactory,
27-
IResourceHookExecutor hookExecutor = null)
28-
: base(repository, queryLayerComposer, paginationContext, options, loggerFactory,
27+
IResourceHookExecutorFacade hookExecutor)
28+
: base(repositoryAccessor, queryLayerComposer, paginationContext, options, loggerFactory,
2929
request, resourceChangeTracker, resourceFactory, hookExecutor)
3030
{
3131
_notificationService = notificationService;
3232
}
3333

34-
public override async Task<TodoItem> CreateAsync(TodoItem resource)
34+
public override async Task<TodoItem> CreateAsync(TodoItem resource, CancellationToken cancellationToken)
3535
{
3636
// Call the base implementation
37-
var newResource = await base.CreateAsync(resource);
37+
var newResource = await base.CreateAsync(resource, cancellationToken);
3838

3939
// Custom code
40-
_notificationService.Notify($"Resource created: {newResource.StringId}");
40+
await _notificationService.NotifyAsync($"Resource created: {newResource.StringId}");
4141

4242
return newResource;
4343
}
@@ -70,9 +70,9 @@ public class ProductService : IResourceService<Product>
7070
_dao = dao;
7171
}
7272

73-
public Task<IEnumerable<Product>> GetAsync()
73+
public async Task<IReadOnlyCollection<Product>> GetAsync(CancellationToken cancellationToken)
7474
{
75-
return await _dao.GetProductsAsync();
75+
return await _dao.GetProductsAsync(cancellationToken);
7676
}
7777
}
7878
```
@@ -162,15 +162,15 @@ public class ArticlesController : BaseJsonApiController<Article>
162162
{ }
163163

164164
[HttpPost]
165-
public override async Task<IActionResult> PostAsync([FromBody] Article resource)
165+
public override async Task<IActionResult> PostAsync([FromBody] Article resource, CancellationToken cancellationToken)
166166
{
167-
return await base.PostAsync(resource);
167+
return await base.PostAsync(resource, cancellationToken);
168168
}
169169

170170
[HttpDelete("{id}")]
171-
public override async Task<IActionResult>DeleteAsync(int id)
171+
public override async Task<IActionResult>DeleteAsync(int id, CancellationToken cancellationToken)
172172
{
173-
return await base.DeleteAsync(id);
173+
return await base.DeleteAsync(id, cancellationToken);
174174
}
175175
}
176176
```

0 commit comments

Comments
 (0)