Exemple #1
0
            public async Task Render(HttpRequest request, HttpResponse response, ASObject toRender)
            {
                response.ContentType = ConverterHelpers.GetBestMatch(_factory.MimeTypes, request.Headers["Accept"]);

                var doc = await _entryGenerator.Build(toRender);

                await response.WriteAsync(doc.ToString());
            }
Exemple #2
0
            public async Task Render(HttpRequest request, HttpResponse response, ASObject toRender)
            {
                response.ContentType = ConverterHelpers.GetBestMatch(_factory.MimeTypes, request.Headers["Accept"]);
                if (toRender["type"].Any(a => (string)a.Primitive == "Tombstone"))
                {
                    response.StatusCode = 410;
                }

                response.Headers.Add("Access-Control-Allow-Origin", "*");

                var depth = Math.Min(int.Parse(request.Query["depth"].FirstOrDefault() ?? "3"), 5);

                var unflattened = await _flattener.Unflatten(_entityStore, APEntity.From(toRender), depth);

                await response.WriteAsync(unflattened.Serialize(true).ToString());
            }
Exemple #3
0
            public async Task Render(HttpRequest request, HttpResponse response, APEntity toRender)
            {
                response.ContentType = ConverterHelpers.GetBestMatch(_factory.MimeTypes, request.Headers["Accept"]);
                if (toRender.Type.Contains("Tombstone"))
                {
                    response.StatusCode = 410;
                }

                if (request.Method == "POST")
                {
                    response.StatusCode = 201;
                    response.Headers.Add("Location", toRender.Id);
                }

                var depth       = Math.Min(int.Parse(request.Query["depth"].FirstOrDefault() ?? "3"), 5);
                var unflattened = await _flattener.Unflatten(_entityStore, toRender, depth, isOwner : toRender.IsOwner);

                await response.WriteAsync(unflattened.Serialize(true).ToString());
            }