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); } }
public static PublicationStateInfo?GetPublicationStateInfo(this HttpActionContext httpContext) { if (!httpContext.GetItems().TryGetValue(typeof(PublicationStateInfo), out var v)) { return(null); } return((PublicationStateInfo?)v); }
public override void OnActionExecuting(HttpActionContext actionContext) { base.OnActionExecuting(actionContext); var request = actionContext.Request; var headers = request.Headers; var mustPublish = headers.TryGetValues(FusionHeaders.RequestPublication, out var _); if (!mustPublish) { return; } var items = actionContext.GetItems(); var computeContextScope = Computed.BeginCapture(); items.Add(typeof(ComputeContextScope), computeContextScope); }