aspnet / WebHooks

[Archived] Libraries to create and consume web hooks on ASP.NET Core. Project moved to https://github.com/aspnet/AspLabs
Apache License 2.0
627 stars 439 forks source link

Unable to customize RoutePrefix of WebHookRegistrationsController #88

Closed Expecho closed 7 years ago

Expecho commented 7 years ago

Hi,

is it possible to customize the default route prefix of the registration and filter controllers. It is now [RoutePrefix("api/webhooks/registrations")] for the WebHookRegistrationsController controller but we have a different prefix. It seems it is hardcoded in the controller. Will it be possible in the (near) future?

HenrikFrystykNielsen commented 7 years ago

Good question -- I'll have to look at it.

kwal commented 7 years ago

This would be a big help to better fit with our overall routing scheme.

leonardochaia commented 7 years ago

Hey guys, we also require to modify the route prefixes since we already have the /api and also an API versioning system that interferes with the hard-codded prefixes. As a workaround I've created a new controller on my project extending the WebHooks Controllers.

/// <summary>
/// Overriding this controller to override the route prefix..
/// </summary>
[Authorize]
[RoutePrefix("webhooks/filters")]
public class WebHookFiltersController 
   : Microsoft.AspNet.WebHooks.Controllers.WebHookFiltersController
{
}

Thanks, Leo.

HenrikFrystykNielsen commented 7 years ago

Ok, I will make it easier to write you own controller and then call into a helper for registration utils. This should help make it easier to get the behavior you want. Will send out an update when ready!

HenrikFrystykNielsen commented 7 years ago

I just committed 757530d2af40da1d51e0cf387595561e1e5cebf0 which makes it much simpler to write your own WebHook registration mechanism whether that is a separate API controller, an MVC controller, or something else entirely. This also gives you full control over how much verification you want to do. Please see the commit for details -- you might be able to look at the existing WebHookRegistrationsController.cs for an example of how it is used.