static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.Register(typeof(Program).Assembly); mApiServer.ServerConfig.BodySerializer = new BeetleX.FastHttpApi.JsonBodySerializer(); mApiServer.Open(); Console.Read(); }
static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.Register(typeof(Program).Assembly); mApiServer.Open(); Console.Write(mApiServer.BaseServer); Console.Read(); }
static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.Options.AddFilter <GlobalFilter>(); mApiServer.Register(typeof(Program).Assembly); mApiServer.Open(); Console.Read(); }
static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.ServerConfig.LogToConsole = true; mApiServer.ServerConfig.LogLevel = BeetleX.EventArgs.LogType.Info; mApiServer.Register(typeof(Program).Assembly); mApiServer.Open(); Console.Write(mApiServer.BaseServer); Console.Read(); }
static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.Register(typeof(Program).Assembly); //config.SSL = true; //mApiServer.ServerConfig.CertificateFile = @"c:\ssltest.pfx"; //mApiServer.ServerConfig.CertificatePassword = "******"; mApiServer.Debug(); mApiServer.Open(); Console.Write(mApiServer.BaseServer); Console.Read(); }
static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.Register(typeof(BeetleX.FastHttpApi.Admin._Admin).Assembly); mApiServer.Register(typeof(Program).Assembly); mApiServer.Options.UrlIgnoreCase = true; mApiServer.Open(); Console.Write(mApiServer.BaseServer); Console.Read(); }
public Server() { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); //mApiServer.Options.LogLevel = BeetleX.EventArgs.LogType.All; mApiServer.Options.LogLevel = BeetleX.EventArgs.LogType.Warring; mApiServer.Options.LogToConsole = true; //mApiServer.Options.SetDebug(); //set view path with vs project folder mApiServer.Register(typeof(Server).Assembly); mApiServer.Options.Port = 8889; //set listen port to 80 mApiServer.Open(); //default listen port 9090 Console.Write(mApiServer.BaseServer); Console.Read(); }
static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.Debug(); mApiServer.Register(typeof(Program).Assembly); mApiServer.Open(); mApiServer.WebSocketReceive = (o, e) => { Console.WriteLine(e.Frame.Body); var freame = e.CreateFrame($"{DateTime.Now}" + e.Frame.Body.ToString()); e.Response(freame); }; Console.Write(mApiServer.BaseServer); Console.Read(); }
static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.Debug(); mApiServer.Register(typeof(BeetleX.FastHttpApi.Admin._Admin).Assembly); mApiServer.Register(typeof(Program).Assembly); mApiServer.HttpRequestNotfound += (o, e) => { BeetleX.FastHttpApi.Move302Result result = new BeetleX.FastHttpApi.Move302Result("/_admin/index.html"); e.Response.Result(result); e.Cancel = true; }; mApiServer.Open(); Console.Write(mApiServer.BaseServer); Console.Read(); }
public Task OpenServer() { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(new BeetleX.FastHttpApi.HttpOptions() { Port = ConfigSettings.Instance.Port, LogLevel = BeetleX.EventArgs.LogType.Warring, Manager = ConfigSettings.Instance.Manager, ManagerPWD = ConfigSettings.Instance.ManagerPWD, SSL = ConfigSettings.Instance.UseSSL, CertificateFile = ConfigSettings.Instance.SSLPath, CertificatePassword = ConfigSettings.Instance.SSLPwd, WriteLog = true, LogToConsole = true, SSLPort = ConfigSettings.Instance.SSLPort, WebSocketMaxRPS = 100000000 }); mApiServer.Debug(); mApiServer.Register(typeof(BeetleX.FastHttpApi.Admin._Admin).Assembly); mApiServer.Register(typeof(Program).Assembly); mApiServer.Open(); Console.Write(mApiServer.BaseServer); Console.Read(); return(Task.CompletedTask); }
public logHandler(BeetleX.FastHttpApi.HttpApiServer sever) { mServer = sever; }
private static void OnSyncData(object state) { BeetleX.FastHttpApi.HttpApiServer server = (BeetleX.FastHttpApi.HttpApiServer)state; if (!Available) { return; } mSyncTimer.Change(-1, -1); try { foreach (var item in new Peanut.Expression().List <DBModules.RefreshBlog>()) { if (item.Status == 1) { DBModules.Blog blog = Peanut.DBContext.Load <DBModules.Blog>(item.BlogID); if (blog != null) { ES.ESBlog eSBlog = new ESBlog(); eSBlog.ID = blog.ID.ToString(); eSBlog.CategoryID = blog.CategoryID; eSBlog.Content = blog.Content; eSBlog.CreateTime = blog.CreateTime; eSBlog.SourceUrl = blog.SourceUrl; eSBlog.Summary = blog.Summary; eSBlog.Category = blog.Category; eSBlog.Tags = blog.Tags; eSBlog.Title = blog.Title; eSBlog.Top = blog.Top; Blog.Put(eSBlog); (DBModules.RefreshBlog.blogID == blog.ID).Delete <DBModules.RefreshBlog>(); if (server.EnableLog(EventArgs.LogType.Info)) { server.Log(EventArgs.LogType.Info, $"update blog {blog.Title} sync to elasticsearch success"); } } } else { (DBModules.RefreshBlog.blogID == item.BlogID).Delete <DBModules.RefreshBlog>(); try { Blog.Delete <ESBlog>(item.BlogID.ToString()); if (server.EnableLog(EventArgs.LogType.Info)) { server.Log(EventArgs.LogType.Info, $"delete blog {item.BlogID} sync to elasticsearch success"); } } catch (Exception e_) { if (server.EnableLog(EventArgs.LogType.Error)) { server.Log(EventArgs.LogType.Error, $"delete blog {item.BlogID} sync to elasticsearch error {e_.Message}"); } } } } } catch (Exception e) { if (server.EnableLog(EventArgs.LogType.Error)) { server.Log(EventArgs.LogType.Error, $"blog sync to elasticsearch error {e.Message}"); } } finally { mSyncTimer.Change(5000, 5000); } }
public static void SyncData(BeetleX.FastHttpApi.HttpApiServer server) { mSyncTimer = new System.Threading.Timer(OnSyncData, server, 5000, 5000); }