summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/StardewModdingAPI.Web/Controllers/ModsController.cs2
-rw-r--r--src/StardewModdingAPI.Web/Framework/InternalControllerFeatureProvider.cs27
-rw-r--r--src/StardewModdingAPI.Web/Framework/RewriteSubdomainRule.cs2
-rw-r--r--src/StardewModdingAPI.Web/Models/ModInfoModel.cs2
-rw-r--r--src/StardewModdingAPI.Web/Models/ModSearchModel.cs2
-rw-r--r--src/StardewModdingAPI.Web/Startup.cs3
6 files changed, 33 insertions, 5 deletions
diff --git a/src/StardewModdingAPI.Web/Controllers/ModsController.cs b/src/StardewModdingAPI.Web/Controllers/ModsController.cs
index 4715d379..79c31c3f 100644
--- a/src/StardewModdingAPI.Web/Controllers/ModsController.cs
+++ b/src/StardewModdingAPI.Web/Controllers/ModsController.cs
@@ -13,7 +13,7 @@ namespace StardewModdingAPI.Web.Controllers
{
/// <summary>Provides an API to perform mod update checks.</summary>
[Produces("application/json")]
- public class ModsController : Controller
+ internal class ModsController : Controller
{
/*********
** Properties
diff --git a/src/StardewModdingAPI.Web/Framework/InternalControllerFeatureProvider.cs b/src/StardewModdingAPI.Web/Framework/InternalControllerFeatureProvider.cs
new file mode 100644
index 00000000..2c24c610
--- /dev/null
+++ b/src/StardewModdingAPI.Web/Framework/InternalControllerFeatureProvider.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Reflection;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Controllers;
+
+namespace StardewModdingAPI.Web.Framework
+{
+ /// <summary>Discovers controllers with support for non-public controllers.</summary>
+ internal class InternalControllerFeatureProvider : ControllerFeatureProvider
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Determines if a given type is a controller.</summary>
+ /// <param name="type">The <see cref="T:System.Reflection.TypeInfo" /> candidate.</param>
+ /// <returns><code>true</code> if the type is a controller; otherwise <code>false</code>.</returns>
+ protected override bool IsController(TypeInfo type)
+ {
+ return
+ type.IsClass
+ && !type.IsAbstract
+ && (/*type.IsPublic &&*/ !type.ContainsGenericParameters)
+ && (!type.IsDefined(typeof(NonControllerAttribute))
+ && (type.Name.EndsWith("Controller", StringComparison.OrdinalIgnoreCase) || type.IsDefined(typeof(ControllerAttribute))));
+ }
+ }
+}
diff --git a/src/StardewModdingAPI.Web/Framework/RewriteSubdomainRule.cs b/src/StardewModdingAPI.Web/Framework/RewriteSubdomainRule.cs
index 9b89cb65..5a56844f 100644
--- a/src/StardewModdingAPI.Web/Framework/RewriteSubdomainRule.cs
+++ b/src/StardewModdingAPI.Web/Framework/RewriteSubdomainRule.cs
@@ -5,7 +5,7 @@ namespace StardewModdingAPI.Web.Framework
{
/// <summary>Rewrite requests to prepend the subdomain portion (if any) to the path.</summary>
/// <remarks>Derived from <a href="https://stackoverflow.com/a/44526747/262123" />.</remarks>
- public class RewriteSubdomainRule : IRule
+ internal class RewriteSubdomainRule : IRule
{
/// <summary>Applies the rule. Implementations of ApplyRule should set the value for <see cref="RewriteContext.Result" /> (defaults to RuleResult.ContinueRules).</summary>
/// <param name="context">The rewrite context.</param>
diff --git a/src/StardewModdingAPI.Web/Models/ModInfoModel.cs b/src/StardewModdingAPI.Web/Models/ModInfoModel.cs
index 180420cd..4e9762e5 100644
--- a/src/StardewModdingAPI.Web/Models/ModInfoModel.cs
+++ b/src/StardewModdingAPI.Web/Models/ModInfoModel.cs
@@ -3,7 +3,7 @@ using Newtonsoft.Json;
namespace StardewModdingAPI.Web.Models
{
/// <summary>Generic metadata about a mod.</summary>
- public class ModInfoModel
+ internal class ModInfoModel
{
/*********
** Accessors
diff --git a/src/StardewModdingAPI.Web/Models/ModSearchModel.cs b/src/StardewModdingAPI.Web/Models/ModSearchModel.cs
index b5bd12fb..b9a73af6 100644
--- a/src/StardewModdingAPI.Web/Models/ModSearchModel.cs
+++ b/src/StardewModdingAPI.Web/Models/ModSearchModel.cs
@@ -1,7 +1,7 @@
namespace StardewModdingAPI.Web.Models
{
/// <summary>Metadata for mods to look up.</summary>
- public class ModSearchModel
+ internal class ModSearchModel
{
/// <summary>The namespaced mod keys to search.</summary>
public string[] ModKeys { get; set; }
diff --git a/src/StardewModdingAPI.Web/Startup.cs b/src/StardewModdingAPI.Web/Startup.cs
index 4806aefe..d5b828b7 100644
--- a/src/StardewModdingAPI.Web/Startup.cs
+++ b/src/StardewModdingAPI.Web/Startup.cs
@@ -11,7 +11,7 @@ using StardewModdingAPI.Web.Framework.ConfigModels;
namespace StardewModdingAPI.Web
{
/// <summary>The web app startup configuration.</summary>
- public class Startup
+ internal class Startup
{
/*********
** Accessors
@@ -44,6 +44,7 @@ namespace StardewModdingAPI.Web
.Configure<ModUpdateCheckConfig>(this.Configuration.GetSection("ModUpdateCheck"))
.AddMemoryCache()
.AddMvc()
+ .ConfigureApplicationPartManager(manager => manager.FeatureProviders.Add(new InternalControllerFeatureProvider()))
.AddJsonOptions(options =>
{
options.SerializerSettings.Formatting = Formatting.Indented;