﻿using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Http;

namespace Hack.TheHub.Controllers
{
    public class JsController : ApiController
    {
     
        public HttpResponseMessage Get(string path)
        {
            HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.OK);

            //using (StreamReader sr = new StreamReader(Path.Combine("Web_Data", "js", path)))
            //{
            //    result = sr.ReadToEnd();
            //}

            //HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.OK);
            //msg.Content = new StringContent(result, System.Text.Encoding.UTF8, "text/javascript"); ;

            msg.Content = new StreamContent(new FileStream(Path.Combine("Web_Data", "js", path), FileMode.Open));
            msg.Content.Headers.ContentType = new MediaTypeHeaderValue("application/javascript");

            return msg;
        }
    }
}
