--- a/src/server/webdav/webdav.c Tue Apr 19 18:34:40 2022 +0200 +++ b/src/server/webdav/webdav.c Tue Apr 19 19:14:49 2022 +0200 @@ -48,8 +48,20 @@ #include "../daemon/protocol.h" #include "../daemon/vfs.h" +/* + * http method fptr mapping + * key: http method name (string) + * value: SAF fptr + */ static UcxMap *method_handler_map; +/* + * webdav backend types + * key: backend name (string) + * value: WebdavBackend* + */ +static UcxMap *webdav_type_map; + static WebdavBackend default_backend; static WSNamespace dav_namespace; @@ -73,10 +85,23 @@ default_backend.instance = NULL; } +int webdav_register_backend(const char *name, webdav_create_func webdavCreate) { + return ucx_map_cstr_put(webdav_type_map, name, webdavCreate); +} + int webdav_init(pblock *pb, Session *sn, Request *rq) { - init_default_backend(); + webdav_type_map = ucx_map_new(8); + if(!webdav_type_map) { + return REQ_ABORTED; + } method_handler_map = ucx_map_new(64); + if(!method_handler_map) { + return REQ_ABORTED; + } + + init_default_backend(); + ucx_map_cstr_put(webdav_type_map, "default", &default_backend); ucx_map_cstr_put(method_handler_map, "OPTIONS", webdav_options); ucx_map_cstr_put(method_handler_map, "PROPFIND", webdav_propfind);