Skip to content

Commit 09879e9

Browse files
committed
return 401 if the repository doesn't find the resource
1 parent 0482a60 commit 09879e9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

JsonApiDotNetCore/Controllers/JsonApiController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ public JsonApiController(JsonApiContext jsonApiContext, ResourceRepository resou
1818
public ObjectResult Get()
1919
{
2020
var entities = _resourceRepository.Get();
21+
if(entities == null || entities.Count == 0) {
22+
return new NotFoundObjectResult(null);
23+
}
2124
return new OkObjectResult(entities);
2225
}
2326

2427
public ObjectResult Get(string id)
2528
{
2629
var entity = _resourceRepository.Get(id);
30+
if(entity == null) {
31+
return new NotFoundObjectResult(null);
32+
}
2733
return new OkObjectResult(entity);
2834
}
2935

0 commit comments

Comments
 (0)