public IHttpContext KeyboardStart(IHttpContext ctx) { Program.KeyboardMapperInstance.Start(); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); return(ctx); }
public IHttpContext ControllerStart(IHttpContext ctx) { Program.ControllerManagerInstance.Start(); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); return(ctx); }
public IHttpContext Index(IHttpContext ctx) { string prefix = ctx.Server.PublicFolder.Prefix; if (string.IsNullOrEmpty(prefix)) { prefix = "/"; } ctx.Response.Redirect($"{prefix}{ctx.Server.PublicFolder.IndexFileName}"); RestServer.CloseResponse(ctx); return(ctx); }
public IHttpContext KeyboardMappingOptions(IHttpContext ctx) { var validMethods = new HttpMethod[] { HttpMethod.GET, HttpMethod.POST, HttpMethod.DELETE, HttpMethod.OPTIONS, }; ctx.Response.Headers["Access-Control-Allow-Methods"] = string.Join(", ", validMethods.Select(x => x.ToString())); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); return(ctx); }
public IHttpContext KeyboardSetCurrentName(IHttpContext ctx) { try { Program.KeyboardMapperInstance.SetCurrentMappingName(ctx.Request.Payload); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); } catch (System.Exception e) { ctx.Response.StatusCode = HttpStatusCode.InternalServerError; RestServer.SendJsonResponse(ctx, new Dictionary <string, object> { { "error", e.Message }, }); } return(ctx); }
public IHttpContext KeyboardRenameMapping(IHttpContext ctx) { try { var json = RestServer.ParseJson(ctx.Request.Payload); Program.KeyboardMapperInstance.RenameMapping((string)json["name"], (string)json["newName"]); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); } catch (System.Exception e) { ctx.Response.StatusCode = HttpStatusCode.InternalServerError; RestServer.SendJsonResponse(ctx, new Dictionary <string, object> { { "error", e.Message }, }); } return(ctx); }