Base solution for your next web application
Open Closed

how to change service mapping #4665


User avatar
0
vladsd created

Is there are easy way to remap services names and uris. For example, I want remap OrganizationUnit to be PreferenceUnit and all APIs associated with OrganizationUnit to be Preference, I am also not a big fan of long path to api. I would like /vX/subject/action As you can see I added versioning to api.

Please advise if you know, thanks a lot.


12 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    you can set your Web API end point address Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder.For<ITaskAppService>("taskSystemV2/task").Build();

    Read the doc <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API">https://aspnetboilerplate.com/Pages/Doc ... ic-Web-API</a>

    check out the post as well #3189

  • User Avatar
    0
    vladsd created

    @alper, thanks.

    For net.core I found When an application service is converted to an MVC Controller, it's default route will look like this: /api/services/<module-name>/<service-name>/<method-name>. For example, if ProductAppService defines a Create method, it's URL will be /api/services/app/product/create (assuming that the module name is 'app').

    So I can change /app/ to /v1/

    1. What about base path, like /api/services/, I want to change '' - empty string so just /api/
    2. What about custom mapping path, for example I want to remap all reference to OgranizationUnits controllers, simply to Groups, can I configure it?

    Thanks for help.

  • User Avatar
    0
    alper created
    Support Team

    hi,

    You cannot change those :( When you see the code it's a literal string in private method. <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Web.Api/WebApi/AbpWebApiModule.cs#L127">https://github.com/aspnetboilerplate/as ... le.cs#L127</a>

  • User Avatar
    0
    vladsd created

    Looks like a simple configuration enhancement?

    Can I override AbpWebApiModule and PostInitialize?

    Thanks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @vladsd, this can be an enhancement on ABP Framework, please create an issue here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues">https://github.com/aspnetboilerplate/as ... ate/issues</a>.

  • User Avatar
    0
    vladsd created

    done, thanks. see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3082">https://github.com/aspnetboilerplate/as ... ssues/3082</a>

  • User Avatar
    0
    alper created
    Support Team

    hi thanks for the feedback. it'll be evaluated for the future releases.

  • User Avatar
    0
    vladsd created

    @ismcagdas, I am surprised such an easy fix did not make into ABP v3.5.0

    Hope you can find a time to include into next update.

    Thank you.

  • User Avatar
    0
    aaron created
    Support Team

    <cite>vladsd: </cite> such an easy fix

    ABP is an open-source framework and your contribution would be appreciated ;)

  • User Avatar
    0
    vladsd created

    I looked into fixing and found that "api/services/" is hard coded all over the place. It is better for creators of the framework to fix such a simple oversight.

  • User Avatar
    0
    aaron created
    Support Team
  • User Avatar
    0
    vladsd created

    FYI,

    For my own services I can map routes with one line: [Route("myroute/[controller]/[action]")] in front AppService definition

    One gotcha - methods needs to be defined for each function.

    What I am asking is a fix for the framework issue.