Example #1
0
        public async Task DispatchAsync(IDashboardContext context)
        {
            var uriMatch = context.UriMatch;
            var pathBase = context.Request.PathBase;

            context.Response.Redirect(pathBase + _redirectLocationFun(uriMatch));

            await Task.CompletedTask;
        }
        public async Task DispatchAsync(IDashboardContext context)
        {
            if (string.IsNullOrWhiteSpace(_staticPath))
            {
                var path = context.UriMatch.Groups[_path].Value;

                context.Response.ContentType = _contentTypeFun(path);
                context.Response.SetExpire(DateTimeOffset.Now.AddYears(1));

                var resourceName = _basePath + "." + getPath(path);
                await WriteResponseAsync(context.Response, resourceName);
            }
            else
            {
                context.Response.ContentType = _contentTypeFun(_staticPath);
                await WriteResponseAsync(context.Response, _staticPath);
            }

            //return Task.FromResult(true);
        }
        //#if NETFULL
        //        [Obsolete("Use the `CommandDispatcher(Func<DashboardContext, bool>)` ctor instead. Will be removed in 2.0.0.")]
        //        public CommandDispatcher(Func<RequestDispatcherContext, bool> command)
        //        {
        //            _command = context => command(RequestDispatcherContext.FromDashboardContext(context));
        //        }
        //#endif

        public async Task DispatchAsync(IDashboardContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            //if (!"POST".Equals(request.Method, StringComparison.OrdinalIgnoreCase))
            //{
            //    response.StatusCode = (int)HttpStatusCode.MethodNotAllowed;
            //    return Task.FromResult(false);
            //}

            if (await _command(context))
            {
                //response.StatusCode = (int)HttpStatusCode.NoContent;
            }
            else
            {
                response.StatusCode = 422;
            }
        }
Example #4
0
        public bool Authorize(IDashboardContext context)
        {
            // if unknown, assume not local
            if (String.IsNullOrEmpty(context.Request.RemoteIpAddress))
            {
                return(false);
            }

            // check if localhost
            if (context.Request.RemoteIpAddress == "127.0.0.1" || context.Request.RemoteIpAddress == "::1")
            {
                return(true);
            }

            // compare with local address
            if (context.Request.RemoteIpAddress == context.Request.LocalIpAddress)
            {
                return(true);
            }

            return(false);
        }
 public GutachterRepository(IDashboardContext context)
 {
     _context = context;
 }
 public GutachterRepository(IDashboardContext context)
 {
     _context = context;
 }