Beispiel #1
0
        public static void Publish(this HttpActionContext httpContext, IPublication publication)
        {
            using var _ = publication.Use();
            var publicationState = publication.State;
            var computed         = publicationState.Computed;
            var isConsistent     = computed.IsConsistent();

            // If exception occurred, response is empty, and we can not assign publication header.
            // If JsonifyAttribute is used, it will do it.
            var responseHeaders = httpContext.Response?.Headers;

            if (responseHeaders != null && responseHeaders.Contains(FusionHeaders.Publication))
            {
                throw Errors.AlreadyPublished();
            }
            var psi = new PublicationStateInfo(publication.Ref, computed.Version, isConsistent);

            var items = httpContext.GetItems();

            items[typeof(IPublicationState)]    = publicationState;
            items[typeof(PublicationStateInfo)] = psi;

            if (responseHeaders != null)
            {
                responseHeaders.AddPublicationStateInfoHeader(psi);
            }
        }
Beispiel #2
0
        public static void Publish(this HttpContext httpContext, IPublication publication)
        {
            using var _ = publication.Use();
            var state        = publication.State;
            var computed     = state.Computed;
            var isConsistent = computed.IsConsistent;

            var headers = httpContext.Response.Headers;

            if (headers.ContainsKey(FusionHeaders.Publication))
            {
                throw Errors.AlreadyShared();
            }
            var psi = new PublicationStateInfo(publication.Ref, computed.Version, isConsistent);

            headers[FusionHeaders.Publication] = JsonConvert.SerializeObject(psi);
        }
Beispiel #3
0
    public static void Publish(this HttpContext httpContext, IPublication publication)
    {
        using var _ = publication.Use();
        var publicationState = publication.State;
        var computed         = publicationState.Computed;
        var isConsistent     = computed.IsConsistent();

        var responseHeaders = httpContext.Response.Headers;

        if (responseHeaders.ContainsKey(FusionHeaders.Publication))
        {
            throw Errors.AlreadyPublished();
        }
        var psi = new PublicationStateInfo(publication.Ref, computed.Version, isConsistent);

        httpContext.Items[typeof(IPublicationState)]    = publicationState;
        httpContext.Items[typeof(PublicationStateInfo)] = psi;
        responseHeaders[FusionHeaders.Publication]      = JsonConvert.SerializeObject(psi);
    }
Beispiel #4
0
        public static void Publish(this HttpContext httpContext, IPublication publication)
        {
            using var _ = publication.Use();
            var state        = publication.State;
            var computed     = state.Computed;
            var isConsistent = computed.IsConsistent;

            var headers = httpContext.Response.Headers;

            if (headers.ContainsKey(FusionHeaders.PublisherId))
            {
                throw Errors.AlreadyShared();
            }
            headers[FusionHeaders.PublisherId]   = publication.Publisher.Id.Value;
            headers[FusionHeaders.PublicationId] = publication.Id.Value;
            headers[FusionHeaders.LTag]          = state.Computed.LTag.ToString();
            if (!isConsistent)
            {
                headers[FusionHeaders.IsConsistent] = isConsistent.ToString();
            }
        }