Add a basic endpoint
This article walks through and example on adding an endpoint which just displays a simple string.
To create an endpoint, create a class that derives from HeadlessApiControllerBase class. Apply the RoutePrefix attribute to the class level, that define the url to this endpoint.
Basic endpoint
For this example, we create a TestPage controller, that would have the url <your domain name>/headlessapi/Test
[RoutePrefix(Routes.RootUri + "/TestPage")]
public class TestPageController:HeadlessApiControllerBase
{
}
Add a HTTP GET method that would simply return a string "This is a test page"
[RoutePrefix(Routes.RootUri + "/TestPage")]
public class TestPageController:HeadlessApiControllerBase
{
[HttpGet]
[Route("", Name = "TestPage")]
public IHttpActionResult Get()
{
return Ok("This is a test page");
}
}
If the Litium instance running is on server.localtest.me, the url to the test page would be, http://server.localtest.me/headlessApi/TestPage
Open postman and send a GET request to this page, would produce following output.
