Last active
November 19, 2018 14:51
-
-
Save hartviglarsen/809a013a98fd5df81d935311d658ab57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using System.Web.Http; | |
| using Umbraco.Web.WebApi; | |
| namespace UmbracoTestApiAttributes.Controllers | |
| { | |
| [RoutePrefix("api/books")] | |
| public class BookController : UmbracoApiController | |
| { | |
| [HttpGet] | |
| [Route("")] | |
| public IEnumerable<string> Index() | |
| { | |
| return new List<string> { "Return of the King", "Valour" }; | |
| } | |
| [HttpGet] | |
| [Route("details/{name}")] | |
| public string Details(string name) | |
| { | |
| return name; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Web.Http; | |
| using Umbraco.Core; | |
| namespace UmbracoTestApiAttributes | |
| { | |
| public class UmbracoApplicationEventHandler : IApplicationEventHandler | |
| { | |
| public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
| { | |
| } | |
| public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
| { | |
| WebApiConfig.Register(GlobalConfiguration.Configuration); | |
| } | |
| public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
| { | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Web.Http; | |
| namespace UmbracoTestApiAttributes | |
| { | |
| public static class WebApiConfig | |
| { | |
| public static void Register(HttpConfiguration config) | |
| { | |
| config.MapHttpAttributeRoutes(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment