File tree Expand file tree Collapse file tree 4 files changed +49
-7
lines changed
src/Umbraco.Commerce.ProductFeeds.Web Expand file tree Collapse file tree 4 files changed +49
-7
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,7 @@ public ProductFeedController(
23
23
public async Task < IActionResult > Xml ( string path )
24
24
{
25
25
ProductFeedSettingReadModel ? feedSettings = await _feedConfigService
26
- . FindSettingAsync ( new FindSettingParams
27
- {
28
- FeedRelativePath = path ,
29
- } )
26
+ . FindSettingAsync ( new FindSettingParams { FeedRelativePath = path } )
30
27
. ConfigureAwait ( true ) ;
31
28
if ( feedSettings == null )
32
29
{
@@ -36,7 +33,8 @@ public async Task<IActionResult> Xml(string path)
36
33
IProductFeedGeneratorService feedGenerator = _feedGeneratorFactory . GetGenerator ( feedSettings . FeedType ) ;
37
34
XmlDocument feed = feedGenerator . GenerateFeed ( feedSettings ) ;
38
35
39
- return Content ( feed . OuterXml , "text/xml" ) ;
36
+ var result = new XmlActionResult ( feed ) { Formatting = Formatting . Indented } ;
37
+ return result ;
40
38
}
41
39
}
42
40
}
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Text ;
3
+ using System . Threading . Tasks ;
4
+ using System . Xml ;
5
+ using Microsoft . AspNetCore . Http ;
6
+ using Microsoft . AspNetCore . Mvc ;
7
+
8
+ namespace Umbraco . Commerce . ProductFeeds . Apis . Public ;
9
+
10
+ public sealed class XmlActionResult : IActionResult
11
+ {
12
+ private static readonly Serilog . ILogger _logger = Serilog . Log . Logger . ForContext ( System . Reflection . MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
13
+
14
+ private readonly XmlDocument _document ;
15
+
16
+ public Formatting Formatting { get ; set ; } = Formatting . None ;
17
+ public string MimeType { get ; set ; } = "text/xml" ;
18
+
19
+ public XmlActionResult ( XmlDocument document )
20
+ {
21
+ ArgumentNullException . ThrowIfNull ( document ) ;
22
+ _document = document ;
23
+ }
24
+
25
+ public async Task ExecuteResultAsync ( ActionContext context )
26
+ {
27
+ context . HttpContext . Response . Clear ( ) ;
28
+ context . HttpContext . Response . ContentType = MimeType ;
29
+
30
+ try
31
+ {
32
+ using ( var writer = new XmlTextWriter ( context . HttpContext . Response . Body , Encoding . UTF8 ) )
33
+ {
34
+ writer . Formatting = Formatting ;
35
+ _document . WriteContentTo ( writer ) ;
36
+ writer . Flush ( ) ;
37
+ }
38
+ }
39
+ catch ( Exception ex )
40
+ {
41
+ _logger . Error ( ex , "Exception generating the XML response" ) ;
42
+ }
43
+ }
44
+ }
Original file line number Diff line number Diff line change 4
4
<Title >Umbraco Commerce Product Feeds Web</Title >
5
5
<Description >Contains apis</Description >
6
6
<Nullable >enable</Nullable >
7
- <NoWarn >IDE0007, CA2007</NoWarn >
7
+ <NoWarn >IDE0007; CA2007</NoWarn >
8
8
<StaticWebAssetBasePath >App_Plugins/umbracocommerceproductfeeds</StaticWebAssetBasePath >
9
9
</PropertyGroup >
10
10
Original file line number Diff line number Diff line change 1
1
{
2
2
"$schema" : " https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json" ,
3
- "version" : " 14.1.1 " ,
3
+ "version" : " 14.1.2 " ,
4
4
"assemblyVersion" : {
5
5
"precision" : " build"
6
6
},
You can’t perform that action at this time.
0 commit comments