Giter VIP home page Giter VIP logo

siesta's People

Contributors

anton-danielsson avatar draugvar avatar jerem584 avatar robiwano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

siesta's Issues

I cannot branch and make a pull request

Hi,
I have done some small bug fix/changes in order to compile with clang on macOS(ARM) but I cannot branch and pull any request. How can I contribute to this project?

Support for CORS and OPTIONS requests

I am attempting to create a basic REST API server using Siesta. However, I encountered an issue while trying to enable support for CORS on PUT requests. The browser initiates a preflight request in the form of an OPTIONS request, resulting in an "error 405 Method Not Allowed." Consequently, CORS verification fails.

I have inspected the code at common.h couldn't find explicit support for OPTIONS requests. Is there a way to enable them?

If there is no direct support, are there any workarounds that could address this issue?

Your assistance is greatly appreciated. Thanks in advance!

Problem with mapping URI

Say I have

holder += httpServer->addRoute(HttpMethod::GET, "/a/:b/:c", foo);
holder += httpServer->addRoute(HttpMethod::GET, "/a", bar);

The above code will work with URI like "/a/bb/cc" being directed to the function foo and "/a" to bar.

However if I switch the order around

holder += httpServer->addRoute(HttpMethod::GET, "/a", bar);
holder += httpServer->addRoute(HttpMethod::GET, "/a/:b/:c", foo);

"/a/bb/cc" can no longer be directed to the correct function.

How to reproduce:

#include <siesta/server.h>
using namespace siesta;

#include <chrono>
#include <iostream>
#include <sstream>
#include <thread>

#include "ctrl_c_handler.h"

void foo(const server::rest::Request& req, server::rest::Response& resp)
{
    std::cout << "This is foo\n" << std::endl;
}
void bar(const server::rest::Request& req, server::rest::Response& resp)
{
    std::cout << "This is bar\n" << std::endl;
}

int main(int argc, char** argv)
{
    ctrlc::set_signal_handler();
    try {
        bool rest_shutdown = false;
        std::string addr   = "http://127.0.0.1:8090";
        if (argc > 1) {
            addr = argv[1];
        }
        auto server = server::createServer(addr);
        server->start();
        std::cout << "Server started, listening on port " << server->port()
                  << std::endl;

        server::TokenHolder h;
        
        h += server->addRoute(HttpMethod::GET, "/a", bar);
        h += server->addRoute(HttpMethod::GET, "/a/:b/:c", foo);
        
        while (!ctrlc::signalled() && !rest_shutdown) {
            std::this_thread::sleep_for(std::chrono::milliseconds(100));
        }

        std::cout << "Server stopped!" << std::endl;
    } catch (std::exception& e) {
        std::cerr << e.what() << std::endl;
        return -1;
    }

    return 0;
}

question about the surveyor pattern

Hi @robiwano ,

Hope you are all well !

I was wondering if it is complicated to extend siesta with the surveyor pattern and replicate what is described in this blog post https://daniel-j-h.github.io/post/distributed-search-nanomsg-bond/ ?

The idea would be to configure rest routes binding several, probably dockerized, respondent clients and aggregate all responses into one. Maybe, using a yaml file to configure the distribution tree ?!

Do you think it is doable ?

Thanks for your inputs and insights on that.

Cheers,
X

Problem with nng_stream

THX for you open source lib 'siesta'. I want to create a websocket server use nng, but I have no idea about how to create it until i found your repo. I read the source code and notice that you use nng_stream to solve it. Maybe there is a question when receive data. The repo use 'nng_stream_recv' to receive websocket data, but nng docs said that 'The I/O operation completes as soon as at least one byte has been received, or an error has occurred'. So it can't ensure that i receive whole data in a request?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.