-
Notifications
You must be signed in to change notification settings - Fork 115
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
[Proposal] Minimal APIs ServiceBase Refactor #241
Closed
5 tasks
Comments
此处为 public class CatalogService: ServiceBase
{
public CatalogService()
{
// 可有可无,设置后优先级将覆盖全局配置
Route.Prefix = "api";
Route.Version = "v2";
Route.PluralizeServiceName = true;
}
} |
按照默认Route规则进行注册:api/v1/{controller}/{id?}/{method} 这里如果参数有id,默认注册为 路由的规则多种多样,无法满足所有情况,如果需要的路由地址为 |
已更新 |
This was
linked to
pull requests
Sep 16, 2022
This was
linked to
pull requests
Dec 21, 2022
In 0.6.0 this has been handled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
假设标准服务写法
优化目标
自动解析ServiceBase,按照默认Route规则进行注册:
{Prefix}/{Version}/{DefaultTrimServiceName(ServiceName)}/{DefaultTrimMethod(method)}
/{id?}DefaultTrimServiceName
DefaultTrimMethod:
PS:如api/v1/user/GetAsync/1,将会变为 api/v1/user/1
优化过程
分离Map到独立的服务文件
program.cs
CatalogService.cs
扫描非当前程序集的ServiceBase
program.cs
修改固定前缀
program.cs,全局设置,注意:所有参数为空则表示忽略,如Version = "",则Url将是
api/{controller}/...
CatalogService.cs,单服务设置
自动注册方法
program.cs,全局设置
CatalogService.cs,单服务设置
个别破坏规则的需要单独指定
CatalogService.cs,单服务设置
任务列表
可以通过 [x] 选择已完成
The text was updated successfully, but these errors were encountered: