欢迎光临,了解微信小程序开发,就上易用通!

微信小程序lianc++后台

发布:2018-02-01 18:29浏览: 来源:网络 作者:tianshu

贴上微信小程序发送http请求代码:

 

[javascript] view plain copy
 
  1. onsend: function(){      
  2.    wx.request({  
  3.       url: 'https://127.0.0.1:1000', //c++后台ip、端口  
  4.       data: {  
  5.           x: '1' , //发送到后台字段  
  6.           y: '2'  
  7.  },  
  8.  header:{  
  9.      "Content-Type":"application/json"  
  10.  },  
  11.  method:"POST", //发送POST,若为GET则改为GET  
[javascript] view plain copy
 
  1. success: function(res) {  
  2.    var data = res.data;  
  3.    console.log(data);  
  4. }  
  5. });  
  6. }  

c++后台代码借鉴boost官网的asio的http server 3地址并自己做了修改:

 

官网地址:https://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio/examples.html

修改代码:

1、request_parser.hpp:

 

[cpp] view plain copy
 
  1. //  
  2. // request_parser.hpp  
  3. // ~~~~~~~~~~~~~~~~~~  
  4. //  
  5. // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)  
  6. //  
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying  
  8. // file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)  
  9. //  
  10.   
  11. #ifndef HTTP_SERVER3_REQUEST_PARSER_HPP  
  12. #define HTTP_SERVER3_REQUEST_PARSER_HPP  
  13.   
  14. #include <boost/logic/tribool.hpp>  
  15. #include <boost/tuple/tuple.hpp>  
  16.   
  17. namespace http {  
  18. namespace server3 {  
  19.   
  20. struct request;  
  21.   
  22. /// Parser for incoming requests.  
  23. class request_parser  
  24. {  
  25. public:  
  26.   /// Construct ready to parse the request method.  
  27.   request_parser();  
  28.   
  29.   /// Reset to initial parser state.  
  30.   void reset();  
  31.   
  32.   /// Parse some data. The tribool r





免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。