/// <summary> /// Called when the <see cref="JsonPacket" /> has been created. Can be overridden to /// adjust the values of the <paramref name="jsonPacket" /> before it is sent to Sentry. /// </summary> /// <param name="jsonPacket">The json packet.</param> /// <returns> /// The <see cref="JsonPacket" />. /// </returns> protected override JsonPacket OnCreate(JsonPacket jsonPacket) { var nancyContext = CallContext.LogicalGetData(NancyConfiguration.NancyContextDataSlot) as NancyContext; if (nancyContext == null) { return(jsonPacket); } var sentryRequest = NancySentryRequest.GetRequest(nancyContext); if (sentryRequest == null) { return(jsonPacket); } jsonPacket.Request = sentryRequest; jsonPacket.User = sentryRequest.GetUser(); return(jsonPacket); }
/// <summary> /// Gets the request. /// </summary> /// <returns> /// If an HTTP contest is available, an instance of <see cref="NancySentryRequest"/>, otherwise <c>null</c>. /// </returns> public static NancySentryRequest GetRequest(NancyContext httpContext) { var request = new NancySentryRequest(httpContext); return request.HasHttpContext ? request : null; }
/// <summary> /// Gets the request. /// </summary> /// <returns> /// If an HTTP contest is available, an instance of <see cref="NancySentryRequest"/>, otherwise <c>null</c>. /// </returns> public static NancySentryRequest GetRequest(NancyContext httpContext) { var request = new NancySentryRequest(httpContext); return(request.HasHttpContext ? request : null); }