using System.Net;
using System.Net.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;

namespace F4SDwebService.ActionFilters
{
    public class CheckCollectorFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            if (WebApiApplication.Collector?.IsValid != true)
                actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Collector was not found or is invalid.");

            base.OnActionExecuting(actionContext);
        }
    }
}