Skip to content
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

Implement and test HTTP verbs other than POST for dynamic API controllers. #142

Closed
hikalkan opened this issue Oct 5, 2014 · 4 comments
Closed
Labels
Milestone

Comments

@hikalkan
Copy link
Member

@hikalkan hikalkan commented Oct 5, 2014

No description provided.

@webzfactory

This comment has been minimized.

Copy link

@webzfactory webzfactory commented Oct 17, 2014

Hi @hikalkan,
Is this related to the issue I have, where trying to make a GET request to the service with an inputDTO is always null ?

You can tell me where to implement these, I will try and do a pull request in the case I am successful...

EDIT:
I found this : http://stackoverflow.com/questions/18735262/can-i-define-custom-attributes-for-proxy-type-in-castle-windsor

I was looking at how to dynamically add the attribute and happened to find your question on the same topic. Did you find any solution ?

@hikalkan

This comment has been minimized.

Copy link
Member Author

@hikalkan hikalkan commented Aug 30, 2015

Implementation notes (will be documented):

  • Prevented web api calls with invalid verbs. For example: if we accept Post, then can not request with GET.
  • WithVerb method is properly working.
  • We can override dynamic web api configuration. We can use ForAll for all services. Then override using For method for a specific service. Example:
DynamicApiControllerBuilder
    .ForAll<IApplicationService>(typeof(MyApplicationModule).Assembly, "app")
    .Build();

DynamicApiControllerBuilder
    .For<ITestAppService>("app/test")
    .ForMethod("MySpecialMethod")
    .WithVerb(HttpVerb.Put)
    .Build();
  • Added WithConventionalVerbs() method to DynamicApiControllerBuilder in order to conventionally select verb by method name. For example, if method name starts with Delete, the verb will be delete. As similar, Put is used if method name starts with Update and Put, Get is used it it starts with Get. Otherwise, Post is used as before. Example:
DynamicApiControllerBuilder
    .ForAll<IApplicationService>(typeof(MyApplicationModule).Assembly, "app")
    .WithConventionalVerbs()
    .Build();
  • Allowed requests without action name if only one action does exists for the current http verb.
  • IMPORTANT: DynamicApiControllerBuilder usage must be in Initialize method of the module. Can not be in PostInitialize.
hikalkan added a commit that referenced this issue Aug 30, 2015
hikalkan added a commit that referenced this issue Aug 30, 2015
@hikalkan hikalkan closed this Aug 30, 2015
@jaq316

This comment has been minimized.

Copy link
Contributor

@jaq316 jaq316 commented Sep 1, 2015

Generation of a Get method with parameters on a service seems to be broken.

Sample of generated code:

    abpModule.factory('abp.services.app.analytics', [
        '$http', function ($http) {
            return new function () {
                this.getRealtime = function (input, httpParams) {
                    return $http(angular.extend({
                        abp: true,
                        url: abp.appPath + 'api/services/app/analytics/GetRealtime',
                        method: 'GET',
                        data: JSON.stringify(input)
                    }, httpParams));
                };

                this.getHistory = function (input, httpParams) {
                    return $http(angular.extend({
                        abp: true,
                        url: abp.appPath + 'api/services/app/analytics/GetHistory',
                        method: 'GET',
                        data: JSON.stringify(input)
                    }, httpParams));
                };

            };
        }
    ]);

The data option should be replaced with the params option. See this SO question

@hikalkan

This comment has been minimized.

Copy link
Member Author

@hikalkan hikalkan commented Sep 2, 2015

OK, I will check it and fix: #595
Thanks a lot.

KenKimura88 pushed a commit to KenKimura88/aspnetboilerplate that referenced this issue Jan 17, 2017
KenKimura88 pushed a commit to KenKimura88/aspnetboilerplate that referenced this issue Jan 17, 2017
KenKimura88 pushed a commit to KenKimura88/aspnetboilerplate that referenced this issue Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.