Example #1
0
        public void Init(HttpApiServer server)
        {
            server.Options.StaticResurceCacheTime = 60 * 5;
            server.UrlRewrite.Add("/cate/{0}.html", "/index.html", "html")
            .Add("/search/{0}.html", "/index.html", "html")
            .Add("/tag/{0}.html", "/index.html", "html")
            .Add("/blog/{0}.html", "/blog.html", "html")
            .Add("/photos/{0}.html", "/photos.html", "html")
            ;
            server.ResourceCenter.FileResponse += (request, e) =>
            {
                if (e.Request.Ext == "jpg" || e.Request.Ext == "png")
                {
                    if (!server.Options.Debug)
                    {
                        e.Response.Header.Add(HeaderTypeFactory.CACHE_CONTROL, "public, max-age=600000");
                    }
                }
            };

            #region init imagepath
            Units.ImagePath = server.Options.StaticResourcePath;
            if (Units.ImagePath[Units.ImagePath.Length - 1] != System.IO.Path.DirectorySeparatorChar)
            {
                Units.ImagePath += System.IO.Path.DirectorySeparatorChar;
            }
            Units.ImagePath += "images" + System.IO.Path.DirectorySeparatorChar;
            if (!System.IO.Directory.Exists(Units.ImagePath))
            {
                System.IO.Directory.CreateDirectory(Units.ImagePath);
            }
            for (int i = 0; i < 10; i++)
            {
                string subpath = Units.ImagePath + i.ToString("00");
                if (!System.IO.Directory.Exists(subpath))
                {
                    System.IO.Directory.CreateDirectory(subpath);
                }
            }
            #endregion
        }
Example #2
0
 public Gateway()
 {
     HttpServer            = new HttpApiServer();
     Routes                = new Routes.RouteCenter(this);
     Agents                = new Servers.ServerCenter(this);
     this.PluginCenter     = new PluginCenter(this);
     this.Pluginer         = new Pluginer(this, null);
     Statistics.Server     = "Gateway";
     AgentMaxSocketError   = 3;
     MaxStatsUrls          = 20000;
     AgentMaxConnection    = 200;
     AgentRequestQueueSize = 2000;
     ThreadQueues          = (Environment.ProcessorCount / 2);
     if (ThreadQueues == 0)
     {
         ThreadQueues = 1;
     }
     GatewayQueueSize = Environment.ProcessorCount * 100;
     InstanceID       = Guid.NewGuid().ToString("N");
     GATEWAY_VERSION  = $"BeetleX/Bumblebee[{GetType().Assembly.GetName().Version.ToString()}]";
 }
Example #3
0
 public Gateway()
 {
     BufferPool.BUFFER_SIZE   = BufferSize;
     BufferPool.POOL_MAX_SIZE = PoolMaxSize;
     HttpServer            = new HttpApiServer();
     Routes                = new Routes.RouteCenter(this);
     Agents                = new Servers.ServerCenter(this);
     this.PluginCenter     = new PluginCenter(this);
     this.Pluginer         = new Pluginer(this, null);
     Statistics.Server     = "Gateway";
     AgentMaxSocketError   = 3;
     MaxStatsUrls          = 2000;
     AgentMaxConnection    = 200;
     AgentRequestQueueSize = 2000;
     ThreadQueues          = (Environment.ProcessorCount / 2);
     if (ThreadQueues == 0)
     {
         ThreadQueues = 1;
     }
     GatewayQueueSize = Environment.ProcessorCount * 500;
     InstanceID       = Guid.NewGuid().ToString("N");
 }
Example #4
0
        public UserInfo GetUserInfo(HttpRequest request)
        {
            string token = request.Cookies[TOKEN_KEY];

            if (string.IsNullOrEmpty(token))
            {
                return(null);
            }
            try
            {
                return(GetUserInfo(token));
            }
            catch (Exception e_)
            {
                HttpApiServer server = request.Server;
                if (server.EnableLog(LogType.Warring))
                {
                    server.Log(LogType.Warring, null, $"{request.RemoteIPAddress} get token error {e_.Message}");
                }
                return(null);
            }
        }
Example #5
0
 public Gateway()
 {
     HttpServer            = new HttpApiServer();
     Routes                = new Routes.RouteCenter(this);
     Agents                = new Servers.ServerCenter(this);
     this.PluginCenter     = new PluginCenter(this);
     this.Pluginer         = new Pluginer(this, null);
     Statistics.Server     = "Gateway";
     AgentMaxSocketError   = 3;
     MaxStatsUrls          = 20000;
     AgentMaxConnection    = 500;
     AgentRequestQueueSize = 500;
     ThreadQueues          = (Environment.ProcessorCount / 2);
     if (ThreadQueues == 0)
     {
         ThreadQueues = 1;
     }
     GatewayQueueSize = Environment.ProcessorCount * 100;
     InstanceID       = Guid.NewGuid().ToString("N");
     GATEWAY_VERSION  = $"beetlex.io";
     TimeoutFactory   = new TimeoutFactory(this);
 }
Example #6
0
        public Gateway()
        {
            HttpServer = new HttpApiServer();
            Filters    = new Filters.FilterCenter(this);
            Routes     = new Routes.RouteCenter(this);
            Agents     = new Servers.ServerCenter(this);
            HttpServer.Options.IOQueueEnabled = true;
            HttpServer.Options.UrlIgnoreCase  = false;
            AgentMaxSocketError     = 5;
            MaxStatsUrls            = 1000;
            AgentMaxConnection      = 300;
            AgentRequestQueueLength = 2000;
            int threads = (Environment.ProcessorCount / 2);

            if (threads == 0)
            {
                threads = 1;
            }
            multiThreadDispatcher = new BeetleX.Dispatchs.DispatchCenter <RequestAgent>(OnExecuteRequest,
                                                                                        Math.Min(threads, 16));
            AgentBufferSize     = 1024 * 8;
            AgentBufferPoolSize = 1024 * 200;
        }
Example #7
0
 public static Gateway GetGateway(HttpApiServer httpApiServer)
 {
     return((Gateway)httpApiServer[GATEWAY_TAG]);
 }
Example #8
0
 public void Init(HttpApiServer server)
 {
     mServer = server;
 }
Example #9
0
 public HttpContext(HttpApiServer server, HttpRequest request, HttpResponse response)
 {
     Request  = request;
     Response = response;
     Server   = server;
 }
Example #10
0
 public void Init(HttpApiServer server)
 {
     this.Server        = server;
     this.HandleFactory = Server.ActionFactory;
 }
Example #11
0
 public void Init(HttpApiServer server, string path)
 {
 }
Example #12
0
 public void Init(HttpApiServer server, string path)
 {
     mPgsql = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance);
 }
Example #13
0
 public Home(HttpApiServer server, UserService userService)
 {
     mHttpApiServer = server;
     mUserService   = userService;
 }