Mongoose publishing problem

Pascal_M
Posts: 3
Joined: Wed Jan 27, 2021 6:37 am

Mongoose publishing problem

Postby Pascal_M » Wed Jan 27, 2021 6:57 am

Hello together,

after playing around with some basics I'd like to serve a directory from spiffs with mongoose.
I started with an example from mongoose.

Code: Select all

if (ev == MG_EV_HTTP_MSG) {
        struct mg_http_message *hm = (struct mg_http_message *) ev_data;
        if (mg_http_match_uri(hm, "/api/config/get")) {
            ESP_LOGD(LOG_TAG, "api/config/get");
            char *s = stringify_config(&s_config);
            mg_printf(c, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s\n",
                      (int) strlen(s) + 1, s);
            free(s);
        } else if (mg_http_match_uri(hm, "/api/config/set")) {
            ESP_LOGD(LOG_TAG, "/api/config/set");
            if (update_config(hm, &s_config)) notify_config_change((struct mg_mgr*) fn_data);
            mg_printf(c, "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
        } else if (mg_http_match_uri(hm, "/api/config/watch")) {
            ESP_LOGD(LOG_TAG, "/api/config/watch");
            c->label[0] = 'W';  // Mark ourselves as a config watcher
            mg_printf(c, "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n");
        } else {
            ESP_LOGD(LOG_TAG, "else");
            struct mg_http_serve_opts opts = {.root_dir = "/www"};

            //mg_http_serve_file(c, (struct mg_http_message*) ev_data, "/www/index.html", "text/html", "AA: bb\r\nCC: dd\r\n");
            mg_http_serve_dir(c,  (struct mg_http_message*) ev_data, &opts);
        }
    }
I serve a web directory (www) but the files are not available in the mongoose context.
To be sure the files are available I did the following:

Code: Select all

    FileSystem *file = new FileSystem();
    std::vector<File> test = file->getDirectoryContents("/www");

    for(int i = 0; i < test.size(); i++) {
        cout << test[i].getName();
    }
The output returns all filename so they are available at the filesystem.
I tried to do the same with mg_http_serve_file but it didn't work, too.

Whats going wrong and why can't mongoose find the files to server? Can someone help me?

Kind Regards

Pascal_M
Posts: 3
Joined: Wed Jan 27, 2021 6:37 am

Re: Mongoose publishing problem

Postby Pascal_M » Tue Feb 02, 2021 7:57 am

Can nobody help me? :?: :(

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: Mongoose publishing problem

Postby ESP_Sprite » Wed Feb 03, 2021 1:36 am

You might be better off trying to see if Mongoose has some way of giving you support... the fraction of people on this forum who use it is not too large, I'd guess.

Who is online

Users browsing this forum: No registered users and 89 guests