Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

Structuring an embedded web server API recommendations

I know there are a lot of samples on the Github repository. I want to build a JSON based API on my embedded device. The examples given only show how to do a basic reply to a request.

In particular i wonder how to structure the app if i have URL paths like /api/v1/model/ and various HTTP Verbs like GET/POST/PUT/DELETE

I will have to do authentication checks on url paths as well and do some json encoding (i know there is the frozen lib)

I wonder if there are any best practices or bigger application examples that i can take a look at before i start doing it my way. I know how to write these kind of applications in other languages like Java, PHP, JavaScript but i have never done it in C.

I know this is more of a general question, but maybe there are some bigger mongoose applications out there.

Cheers, Friedrich


  • SergeySergey Dublin, Ireland

    Embedded devices usually are not sophisticated, so the API can be simply structured.
    Can you elaborate a bit more on your task please?
    Are you writing a device dashboard? or only a RESTful interface to interrogate data? Can device be controlled through the API?
    Is simple Digest auth enough, or you'd like to go with two-way SSL or Cookie-based auth?

  • pfriedpfried Germany Stuttgart

    The device will serve a Single Page Application which exchanges data models with the embedded device through an API. Basically exchanging settings. Later on we will add live data for drawing graphs.

    I am just asking for examples, because i found some helper functions like checking for a prefix or comparing http verbs quite helpful.

    The authentication will be done with JWT, but that should be straightforward and i think i will implement it as a kind of middleware to the routes. There is also some user management and access control to it.

    This is really not much of a specific technical question, but more for best practices and more sophisticated examples, i thought maybe you know some open source projects using restful http APIs in a more sophisticated manner.

  • pfriedpfried Germany Stuttgart

    Yes i saw them, the basic usage of mongoose is clear. I thought more about some real world examples. But dont feel obligated to provide an "answer" here. Im fine with the examples and will get along with them

  • SergeySergey Dublin, Ireland

    If you give us more concrete use case, we'll consider implementing it.
    Do you have something in mind?

Sign In or Register to comment.