* Extended the Restconf implementation with a limited www-data

* This is an experimental implementation
  * Added `www-data` feature and two new config options to clixon-config.yang:
     * `CLICON_WWW_DATA_PATH`
     * `CLICON_WWW_DATA_ROOT`
  * The limited implemtation is as follows:
     * path: Local files within `CLICON_WWW_DATA_ROOT`
     * operation GET, HEAD, or OPTIONS
     * query parameters not supported
     * indata should be NULL (no write operations)
     * Limited media: text/html, JavaScript, image, and css
     * Authentication as restconf
Generic changes:
  * Uniform path selection across fcgi, native http/1 + http/2
This commit is contained in:
Olof hagsand 2022-04-19 09:24:40 +02:00
parent e1bec5f6dd
commit 76213057b6
16 changed files with 572 additions and 41 deletions

View file

@ -70,6 +70,28 @@
#include "restconf_methods_get.h"
#include "restconf_methods_post.h"
/*! Check if uri path denotes a restconf path
*
* @retval 0 No, not a restconf path
* @retval 1 Yes, a restconf path
*/
int
api_path_is_restconf(clicon_handle h)
{
char *path;
char *restconf_path = RESTCONF_API;
if ((path = restconf_uripath(h)) == NULL)
return 0;
if (strlen(path) < 1 + strlen(restconf_path)) /* "/" + restconf */
return 0;
if (path[0] != '/')
return 0;
if (strncmp(path+1, restconf_path, strlen(restconf_path)) != 0)
return 0;
return 1;
}
/*! Determine the root of the RESTCONF API by accessing /.well-known
* @param[in] h Clicon handle
* @param[in] req Generic Www handle (can be part of clixon handle)