-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1351 #1510 New AddOcelot extensions to support custom ASP.NET MVC pipeline building via the IMvcCoreBuilder interface #1655
#1351 #1510 New AddOcelot extensions to support custom ASP.NET MVC pipeline building via the IMvcCoreBuilder interface #1655
Conversation
@raman-m This PR allows users to use their desired JSON library for serialization, such as For example: service.AddOcelotUsingBuilder((builder, assembly) =>
{
return builder
.AddApplicationPart(assembly)
.AddControllersAsServices()
.AddAuthorization()
.AddJsonOptions(); // use System.Text.Json
}); This is just one of the common usages, users can add more modules they need in the builder. |
Related to: #1515 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @guoyongchang ! I'm just curious, what's your name?
I've made some refactoring and styling issue fixes. Hope it is useful! 😸
Could you add your user scenario from your the comment as acceptance test please, to make sure new Json lib is used?
You are welcome to show more techniques with MVC core builder.
Also, I am pleasantly asking you to add unit tests for new extension methods to files: OcelotBuilderTests
Or make new code files in the folder: DependencyInjection
You can call me guo, and the name of github is my full Chinese name in pinyin. Maybe you can understand Yongchang Guo? Nice change. I've tested it with no problems, and there will be no other confusion caused by shortened method names. I think this function is usually used when integrating with existing API projects, so I put the unit test in About more techniques with MVC core builder, I think that as long as a custom method is provided, all the default things can be overridden, for example, I only need to change the default Json Provider, maybe others need to add more assemblies, or change the default authentication. Wrote into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guoyongchang Thanks, Guo!
Good job!
@geffzhang Could you review please? |
Thank you for the PR, please fix the merge conflicts and update the docs so people know how to use this and I'm happy to merge! |
@geffzhang Geff, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Merge conflicts have been resolved after updating with new top commits from develop branch
- Added new Dependency Injection feature in documentation
- Added unit tests for the
OcelotBuilder
class to coverAddOcelotUsingBuilder
methods
@TomPallister wrote on Jun 4, 2023
Done! See the message above plz! Tom, could you review and merge it please? |
Fix target framework as net7.0
Use correct heading levels for (sub)sections
Readability improvements
Overview paragraph
"IServiceCollection extensions" paragraph. "The OcelotBuilder class" paragraph.
Mark down corrections
… characters: should_*
f7f695a
to
420bc45
Compare
Closes #1351 #1510
Background
The default
AddOcelot
method adds.AddNewtonsoftJson()
, which was necessary when Microsoft did not launch theSystem.Text.Json
library, but now it affects normal use, so this PR is mainly to solve the problem problem.New Feature
Added the following methods in
Ocelot.DependencyInjection.ServiceCollectionExtensions
AddOcelotWithCustomMvcCoreBuilder(this IServiceCollection services, Func<IMvcCoreBuilder, Assembly, IMvcCoreBuilder> customMvcCoreBuilder)
AddOcelotWithCustomMvcCoreBuilder(this IServiceCollection services, IConfiguration configuration, Func<IMvcCoreBuilder, Assembly, IMvcCoreBuilder> customMvcCoreBuilder)
Proposed Changes
MvcCoreBuilder
to adapt to more changes in the future, this change is mainly to supportSystem.Text.Json