-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
encapsulate project to injectable parts #28
Comments
Great idea @snys98. I think it's absolutely possible. I want to prepare the REST api like you mentioned. What do you suggest with UI part? Thank you for your feedback. :) |
I am working on REST api, but I am wondering how distribute the set of controllers as nuget package - what do you think about it @snys98? I think - it is possible to add into nuget package some repositories and services that are connected with database model but what about api endpoints? :) |
Maybe we should forget about the MVC pattern but try to implement a middleware instead. I suggest all these could be done with a single line in the pipeline, like:
Then the api endpoint("/identity-admin") should deal with all the request that has the url prefix of "identity-admin" then map the sub-urls to corresponding handler functions. |
I've found the solution, that it's possible to add controllers from another assembly like this: services.AddMvc()
.AddApplicationPart(typeof(ClientController).Assembly)
.AddControllersAsServices(); This post describes how to implement dynamic routing with another assembly. I've built extension method like this: public static IServiceCollection AddIdentityServerAdminApi(this IServiceCollection services, Action<ApiRouteConfiguration> configureRoute)
{
var options = new ApiRouteConfiguration();
services.AddSingleton(options);
configureRoute?.Invoke(options);
var serviceProvider = services.BuildServiceProvider();
var apiRouteConfiguration = serviceProvider.GetService<ApiRouteConfiguration>();
services.AddMvc()
.AddApplicationPart(typeof(ClientController).Assembly)
.AddControllersAsServices()
.AddApiRoutingConfiguration(apiRouteConfiguration); //based on the SO post
return services;
} In services.AddIdentityServerAdminApi(configuration =>
{
configuration.ApiPrefix = "admin-ui/api/";
}); What do you think about it? I've wondered about custom middleware and I think this approach above it's better because in custom middleware you are working with "raw" http request and you need implement everything from scratch. :) |
@snys98 Great point. I am working on it but I can't find any solution how to share the resources for localization. Razor class library provides great posibilities how to share UI across among multiple projects, but all available samples are without localization. Any idea? :) |
Similiar use case with sharing resx files from class library - aspnet/Localization#328
.nuspec: <?xml version="1.0"?>
<package>
<metadata>...
</metadata>
<files>
<!-- Add all resource files -->
<file src="Resources\**\*.resx" target="content\Resources" />
</files>
</package> |
@skoruba |
@snys98 Yes, it seems the combination of Razor Class Library and Resources for localization working well. I am currently working on splitting the solution into three parts:
After that I'll create some nuget packages. Again - thank you for your good ideas. 👍 |
I'm wondering if it is possible to change the structure of this project to two different projects(or nuget packages would be better).
IdentityServer4.Admin
this project will register all operations to a specific endpoint(like "/identity-server-admin") as a rest api.
IdentityServer4.Admin.UI
this project will register all default page to a specific endpoint(like "/identity-server-admin-ui") and it would be possible to inject some css or js or something.
Just like what swagger&swagger-ui has done.
Besides, thanks for your huge efforts for this repo.
The text was updated successfully, but these errors were encountered: