public static void Main(string[] args) { Logger.Info("Starting up"); var server = new HttpServer(Configuration.HttpServerPort); var bazar = new Bazar(server); var api = new RestAPI(server, bazar); if (!File.Exists(Configuration.BazarPersistentFile)) { bazar.CreateChannel("/", Configuration.DefaultChannelName, Configuration.DefaultChannelDescription); } ; bazar.Save(); server.Start(); (new ManualResetEvent(false)).WaitOne(); }
private string Create(HttpListenerRequest req, HttpListenerResponse res, string endpoint) { if (_badNamesRegex.Match(endpoint).Success) { return(BadRequest(res, "forbidden endpoint endpoint is invalid")); } var channel = Bazar.Get(endpoint); if (channel != null && !Security.Instance.CanWrite(channel, req.QueryString.Get("key"))) { return(Unauthorized(res)); } var name = req.QueryString.Get("name"); var description = req.QueryString.Get("description"); var c = Bazar.CreateChannel(endpoint, name, description); Bazar.Save(); return(JsonConvert.SerializeObject(c.JSON(), Formatting.Indented)); }