コード例 #1
0
        public PagingLinkBuilder(RequestContextDelegate requestPath, RequestContextDelegate requestQuery)
        {
            this.requestPath = requestPath;

            // Create the dictionary of query string values.
            list = QueryHelpers.ParseQuery(requestQuery());
            //list = QueryHelpers.ParseQuery(context.Request.QueryString.ToString());
            // context.Request.Path
        }
コード例 #2
0
        public void Write(HttpContext context, long offset, int limit, long total)
        {
            RequestContextDelegate requestPath  = delegate { return(context.Request.Path); };
            RequestContextDelegate requestQuery = delegate { return(context.Request.QueryString.ToString()); };

            PagingLinkBuilder builder = new PagingLinkBuilder(requestPath, requestQuery);
            List <PageLink>   links   = builder.Links(offset, limit, total);

            context.Response.Headers["Access-Control-Allow-Headers"]  = "*";
            context.Response.Headers["Access-Control-Allow-Origin"]   = "*";
            context.Response.Headers["Access-Control-Expose-Headers"] = "*";
            //context.Response.Headers["Access-Control-Expose-Headers"] = "Content-Length,Link,Pagination-Returned,Pagination-Total";

            context.Response.Headers["Link"] = string.Join(", ", links.Select(l => l.Url));
            context.Response.Headers["Pagination-Offset"] = offset.ToString();
            context.Response.Headers["Pagination-Limit"]  = limit.ToString();
            context.Response.Headers["Pagination-Total"]  = total.ToString();
        }