private void onRequest(HttpListenerContext context) { var req = context.Request; var res = context.Response; var eventArgs = new HttpRequestEventArgs(context); if (req.HttpMethod == "GET" && !OnGet.IsNull()) { OnGet(this, eventArgs); return; } if (req.HttpMethod == "HEAD" && !OnHead.IsNull()) { OnHead(this, eventArgs); return; } if (req.HttpMethod == "POST" && !OnPost.IsNull()) { OnPost(this, eventArgs); return; } if (req.HttpMethod == "PUT" && !OnPut.IsNull()) { OnPut(this, eventArgs); return; } if (req.HttpMethod == "DELETE" && !OnDelete.IsNull()) { OnDelete(this, eventArgs); return; } if (req.HttpMethod == "OPTIONS" && !OnOptions.IsNull()) { OnOptions(this, eventArgs); return; } if (req.HttpMethod == "TRACE" && !OnTrace.IsNull()) { OnTrace(this, eventArgs); return; } if (req.HttpMethod == "CONNECT" && !OnConnect.IsNull()) { OnConnect(this, eventArgs); return; } if (req.HttpMethod == "PATCH" && !OnPatch.IsNull()) { OnPatch(this, eventArgs); return; } res.StatusCode = (int)HttpStatusCode.NotImplemented; }