Skip to content

Commit c522082

Browse files
authored
Merge pull request #6541 from erikjanwestendorp/update-cache-tags
Porting old Umbraco API Controller [Cache > Tags]
2 parents 1f6f9c5 + 5632b4a commit c522082

File tree

4 files changed

+14
-22
lines changed
  • 10/umbraco-cms/reference/cache/examples
  • 13/umbraco-cms/reference/cache/examples
  • 14/umbraco-cms/reference/cache/examples
  • 15/umbraco-cms/reference/cache/examples

4 files changed

+14
-22
lines changed

10/umbraco-cms/reference/cache/examples/tags.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ For this example we're working with tags. On my site I have two tag properties:
1818

1919
We're going to expose an endpoint that allows us to get the tags from each group.
2020

21-
The tags from the `default` should be cached for a minute and the `blog` tags will be cached until site restart or if you publish a blog post node in the Backoffice.
21+
The tags from the `default` should be cached for a minute. The `blog` tags will be cached until site restart or if you publish a blog post node in the Backoffice.
2222

2323
## Example
2424

13/umbraco-cms/reference/cache/examples/tags.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ For this example we're working with tags. On my site I have two tag properties:
1616

1717
We're going to expose an endpoint that allows us to get the tags from each group.
1818

19-
The tags from the `default` should be cached for a minute and the `blog` tags will be cached until site restart or if you publish a blog post node in the Backoffice.
19+
The tags from the `default` should be cached for a minute. The `blog` tags will be cached until site restart or if you publish a blog post node in the Backoffice.
2020

2121
## Example
2222

14/umbraco-cms/reference/cache/examples/tags.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ For this example we're working with tags. On my site I have two tag properties:
1616

1717
We're going to expose an endpoint that allows us to get the tags from each group.
1818

19-
The tags from the `default` should be cached for a minute and the `blog` tags will be cached until site restart or if you publish a blog post node in the Backoffice.
19+
The tags from the `default` should be cached for a minute. The `blog` tags will be cached until site restart or if you publish a blog post node in the Backoffice.
2020

2121
## Example
2222

@@ -108,22 +108,18 @@ Now you can inject `ICacheTagService` in any constructor in your project - wohoo
108108

109109
Now that we have our service it's time to create an endpoint where we can fetch the (cached) tags.
110110

111-
{% hint style="warning" %}
112-
The example below uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15.
113-
{% endhint %}
114-
115111
```csharp
116112
using System;
117113
using System.Collections.Generic;
118114
using Microsoft.AspNetCore.Mvc;
119115
using Doccers.Core.Services;
120116
using Umbraco.Cms.Core.Models;
121-
using Umbraco.Cms.Web.Common.Controllers;
122-
123117

124118
namespace Doccers.Core.Controllers.Api;
125119

126-
public class TagsController : UmbracoApiController
120+
[ApiController]
121+
[Route("/umbraco/api/tags")]
122+
public class TagsController : Controller
127123
{
128124
private readonly ICacheTagService _tagService;
129125

@@ -133,7 +129,7 @@ public class TagsController : UmbracoApiController
133129
_tagService = tagService;
134130
}
135131

136-
[HttpGet]
132+
[HttpGet("getdefaulttags")]
137133
public IEnumerable<TagModel> GetDefaultTags()
138134
{
139135
// As mentioned earlier we want tags from "default"
@@ -142,7 +138,7 @@ public class TagsController : UmbracoApiController
142138
TimeSpan.FromMinutes(1));
143139
}
144140

145-
[HttpGet]
141+
[HttpGet("getblogtags")]
146142
public IEnumerable<TagModel> GetBlogTags()
147143
{
148144
// If you don't specify a TimeSpan the object(s)

15/umbraco-cms/reference/cache/examples/tags.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ For this example we're working with tags. On my site I have two tag properties:
1616

1717
We're going to expose an endpoint that allows us to get the tags from each group.
1818

19-
The tags from the `default` should be cached for a minute and the `blog` tags will be cached until site restart or if you publish a blog post node in the Backoffice.
19+
The tags from the `default` should be cached for a minute. The `blog` tags will be cached until site restart or if you publish a blog post node in the Backoffice.
2020

2121
## Example
2222

@@ -108,22 +108,18 @@ Now you can inject `ICacheTagService` in any constructor in your project - wohoo
108108

109109
Now that we have our service it's time to create an endpoint where we can fetch the (cached) tags.
110110

111-
{% hint style="warning" %}
112-
The example below uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15.
113-
{% endhint %}
114-
115111
```csharp
116112
using System;
117113
using System.Collections.Generic;
118114
using Microsoft.AspNetCore.Mvc;
119115
using Doccers.Core.Services;
120116
using Umbraco.Cms.Core.Models;
121-
using Umbraco.Cms.Web.Common.Controllers;
122-
123117

124118
namespace Doccers.Core.Controllers.Api;
125119

126-
public class TagsController : UmbracoApiController
120+
[ApiController]
121+
[Route("/umbraco/api/tags")]
122+
public class TagsController : Controller
127123
{
128124
private readonly ICacheTagService _tagService;
129125

@@ -133,7 +129,7 @@ public class TagsController : UmbracoApiController
133129
_tagService = tagService;
134130
}
135131

136-
[HttpGet]
132+
[HttpGet("getdefaulttags")]
137133
public IEnumerable<TagModel> GetDefaultTags()
138134
{
139135
// As mentioned earlier we want tags from "default"
@@ -142,7 +138,7 @@ public class TagsController : UmbracoApiController
142138
TimeSpan.FromMinutes(1));
143139
}
144140

145-
[HttpGet]
141+
[HttpGet("getblogtags")]
146142
public IEnumerable<TagModel> GetBlogTags()
147143
{
148144
// If you don't specify a TimeSpan the object(s)

0 commit comments

Comments
 (0)