简体   繁体   English

在webapi中自定义数据注释?

[英]customize data annotation in webapi?

right now I am doing WebAPI and as we know each controller will have its own url. 现在我正在做WebAPI,我们知道每个控制器都有自己的URL。 Do have option to change those url what ever we like. 确实可以选择更改这些url,无论我们喜欢什么。 Per example below urls are current Web API. 网址下方的每个示例都是当前的Web API。

Do we really want to use mixed case in urls?
            - http://localhost:8282/api/encode/
            - http://localhost:8282/api/techdisciplines/
            - http://localhost:8282/api/memstatus/
            - http://localhost:8282/api/isstaff/

Want to change them to below url with changing major code effect. 想要通过更改主要代码效果将它们更改为url以下。 Just changing data annotation. 只是更改数据注释。

         - http://localhost:8282/api/cus/encode/<customer id>
        - http://localhost:8282/api/cus/disciplines/<token>
        - http://localhost:8282/api/cus/mem_status/<token>
        - http://localhost:8282/api/cus/is_staff/<token>

Like Java has which automatically find the method. 像Java一样具有自动查找方法。

    @Path("customer/{i_Constit}/subscriptions")
    public Response getSubscriptions(@PathParam("i_Constit") String customerId)
    {
                          ....
                          ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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