简体   繁体   中英

ABP Rename API Route in Controller as a Service

Using ABP service as controller, a default route as such will be generated for a TaskService get method: /api/services/app/taskservice/gettask

  1. is it by default that the "service" word will also appear for task service like /taskservice in the route instead of just /task? If it's not, what could be wrong in my setup?

  2. If it is, how can I remove it? Like in controller level, I can have api route as such /api/v1/task/gettask by having data annotation below. Is there something similar in service level (which has module name as well)

    [Route("api/v{version:apiVersion}/[controller]")]

The service have to named as "AppService" as the postfix instead of just "Service"

By default, only the following postfixes are removed:

public static string[] CommonPostfixes = { "AppService", "ApplicationService" };

You can do either of these:

  1. Name it TaskAppService .
  2. Configure ApplicationService.CommonPostfixes in your module's PreInitialize method.
ApplicationService.CommonPostfixes = new string[] { "Service", "AppService", "ApplicationService" };

References:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM