void OnEnable() { if (Server == null) { Server = new uHTTP.Server(port); } Server.requestHandler = (uHTTP.Request request) => { if (request.Method.ToUpper().Equals("POST")) { Dispatcher.Invoke(() => { if (postRequestHandler != null) { postRequestHandler.Invoke(request.Url, request.Body); } }); uHTTP.Response response = new uHTTP.Response(uHTTP.StatusCode.OK); response.Headers.Add("Access-Control-Allow-Origin", "*"); return(response); } return(new uHTTP.Response(uHTTP.StatusCode.ERROR)); }; if (StartStopAutomatically && !Server.IsRunning) { Server.Start(); } }
void OnEnable() { if (Server == null) { Server = new uHTTP.Server(port); } Server.requestHandler = OnRequest; if (StartStopAutomatically && !Server.IsRunning) { Server.Start(); } }