* Stub code for http server * can send a response, cannot process body yet * write headers to the response * remove commented code * add simple test + set default http handler * tweak CI + unittest * add missing file * rewrite http::trim in a simple way * doc
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 *  IXTest.h
 | 
						|
 *  Author: Benjamin Sergeant
 | 
						|
 *  Copyright (c) 2018 Machine Zone. All rights reserved.
 | 
						|
 */
 | 
						|
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include <iostream>
 | 
						|
#include <ixwebsocket/IXWebSocketServer.h>
 | 
						|
#include "IXGetFreePort.h"
 | 
						|
#include <mutex>
 | 
						|
#include <spdlog/spdlog.h>
 | 
						|
#include <sstream>
 | 
						|
#include <string>
 | 
						|
#include <vector>
 | 
						|
 | 
						|
namespace ix
 | 
						|
{
 | 
						|
    // Sleep for ms milliseconds.
 | 
						|
    void msleep(int ms);
 | 
						|
 | 
						|
    // Generate a relatively random string
 | 
						|
    std::string generateSessionId();
 | 
						|
 | 
						|
    // Record and report websocket traffic
 | 
						|
    void setupWebSocketTrafficTrackerCallback();
 | 
						|
    void reportWebSocketTraffic();
 | 
						|
 | 
						|
    struct Logger
 | 
						|
    {
 | 
						|
    public:
 | 
						|
        template<typename T>
 | 
						|
        Logger& operator<<(T const& obj)
 | 
						|
        {
 | 
						|
            std::lock_guard<std::mutex> lock(_mutex);
 | 
						|
 | 
						|
            std::stringstream ss;
 | 
						|
            ss << obj;
 | 
						|
            spdlog::info(ss.str());
 | 
						|
            return *this;
 | 
						|
        }
 | 
						|
 | 
						|
    private:
 | 
						|
        static std::mutex _mutex;
 | 
						|
    };
 | 
						|
 | 
						|
    void log(const std::string& msg);
 | 
						|
 | 
						|
    bool startWebSocketEchoServer(ix::WebSocketServer& server);
 | 
						|
} // namespace ix
 |