CreateFromHttpRequest() 공개 정적인 메소드

Converts a standard HttpRequest to a RequestModel Copies over: URL, HTTP method, HTTP headers, query string params, POST params, user IP, route params
public static CreateFromHttpRequest ( HttpRequest request, System.Web.SessionState.HttpSessionState session, string scrubParams = null ) : RollbarSharp.Serialization.RequestModel
request System.Web.HttpRequest
session System.Web.SessionState.HttpSessionState
scrubParams string
리턴 RollbarSharp.Serialization.RequestModel
예제 #1
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body)
        {
            var model = new DataModel(level, body);

            model.CodeVersion = Configuration.CodeVersion;
            model.Environment = Configuration.Environment;
            model.Platform    = Configuration.Platform;
            model.Language    = Configuration.Language;
            model.Framework   = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            var currentHttpRequest = GetCurrentHttpRequest();

            if (currentHttpRequest == null)
            {
                model.Request = new RequestModel();
                model.Server  = new ServerModel();
                model.Person  = new PersonModel();
            }
            else
            {
                model.Request = RequestModelBuilder.CreateFromHttpRequest(currentHttpRequest, HttpContext.Current.Session, Configuration.ScrubParams);
                model.Server  = ServerModelBuilder.CreateFromHttpRequest(currentHttpRequest);
                model.Person  = PersonModelBuilder.CreateFromHttpRequest(currentHttpRequest);
            }

            model.Server.GitSha = Configuration.GitSha;

            return(model);
        }
예제 #2
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body, IDictionary <string, string> requestSession, PersonModel person)
        {
            var model = new DataModel(level, body);

            model.CodeVersion = Configuration.CodeVersion;
            model.Environment = Configuration.Environment;
            model.Platform    = Configuration.Platform;
            model.Language    = Configuration.Language;
            model.Framework   = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            var currentHttpRequest = GetCurrentHttpRequest();

            if (currentHttpRequest == null)
            {
                model.Request = new RequestModel();
                model.Server  = new ServerModel();
                model.Person  = new PersonModel();
            }
            else
            {
                model.Request = RequestModelBuilder.CreateFromHttpRequest(currentHttpRequest, HttpContext.Current.Session, Configuration.ScrubParams);
                model.Server  = ServerModelBuilder.CreateFromHttpRequest(currentHttpRequest);
                model.Person  = PersonModelBuilder.CreateFromHttpRequest(currentHttpRequest);
            }

            if (requestSession != null)
            {
                foreach (var key in requestSession.Keys)
                {
                    model.Request.Session[key] = requestSession[key];
                }
            }

            if (person != null)
            {
                model.Person.Email    = person.Email ?? model.Person.Email;
                model.Person.Id       = person.Id ?? model.Person.Id;
                model.Person.Username = person.Username ?? model.Person.Username;
            }

            model.Server.GitSha = Configuration.GitSha;

            return(model);
        }