using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Http;
using System.Web.Http.SelfHost;

namespace WebApi.SelfHostingExample
{
    class Program
    {
        static void Main(string[] args)
        {
            var configuration = new HttpSelfHostConfiguration( "http://localhost:8080" );

            configuration.Routes.MapHttpRoute(
                name: "DefaultRoute",
                routeTemplate: "endpoints/{controller}",
                defaults: null );

            using ( var server = new HttpSelfHostServer(configuration) )
            {
                var formatters = server.Configuration.Formatters;
                formatters.Remove( formatters.XmlFormatter );

                server.OpenAsync().Wait();

                Console.WriteLine("We are up and running at http://localhost:8080/");

                Console.ReadLine();
            }
        }
    }
}
