Jelajahi Sumber

Add PATCH handlers to the CivetServer

Neil Jensen 9 tahun lalu
induk
melakukan
76b1fbd5cf
2 mengubah file dengan 19 tambahan dan 0 penghapusan
  1. 9 0
      include/CivetServer.h
  2. 10 0
      src/CivetServer.cpp

+ 9 - 0
include/CivetServer.h

@@ -86,6 +86,15 @@ class CIVETWEB_API CivetHandler
 	 * @returns true if implemented, false otherwise
 	 */
 	virtual bool handleOptions(CivetServer *server, struct mg_connection *conn);
+
+	/**
+	 * Callback method for PATCH request.
+	 *
+	 * @param server - the calling server
+	 * @param conn - the connection information
+	 * @returns true if implemented, false otherwise
+	 */
+	virtual bool handlePatch(CivetServer *server, struct mg_connection *conn);
 };
 
 /**

+ 10 - 0
src/CivetServer.cpp

@@ -40,6 +40,14 @@ CivetHandler::handlePut(CivetServer *server, struct mg_connection *conn)
 }
 
 bool
+CivetHandler::handlePatch(CivetServer *server, struct mg_connection *conn)
+{
+	UNUSED_PARAMETER(server);
+	UNUSED_PARAMETER(conn);
+	return false;
+}
+
+bool
 CivetHandler::handleDelete(CivetServer *server, struct mg_connection *conn)
 {
 	UNUSED_PARAMETER(server);
@@ -126,6 +134,8 @@ CivetServer::requestHandler(struct mg_connection *conn, void *cbdata)
 			return handler->handleDelete(me, conn) ? 1 : 0;
 		} else if (strcmp(request_info->request_method, "OPTIONS") == 0) {
 			return handler->handleOptions(me, conn) ? 1 : 0;
+		} else if (strcmp(request_info->request_method, "PATCH") == 0) {
+			return handler->handlePatch(me, conn) ? 1 : 0;
 		}
 	}