Crow는 HTTP 또는 WebSocket 웹 서비스를 작성하기위한 C ++ 프레임 워크입니다. Python의 플라스크와 유사한 라우팅을 사용하여 사용하기 쉽습니다. 또한 비 C ++ 프레임 워크뿐만 아니라 여러 기존의 C ++ 프레임 워크를 꺾고 매우 빠릅니다.
쉬운 라우팅 (플라스크와 유사).
유형-안전 핸들러.
멍청하게 빠르게 (이 벤치 마크 와이 벤치 마크 참조).
JSON 지원을 구축했습니다.
콧수염 기반 템플릿 라이브러리 ( crow::mustache
).
헤더 전용 라이브러리 (단일 헤더 파일 사용 가능).
확장에 대한 미들웨어 지원.
HTTP/1.1 및 WebSocket 지원.
다중 부문 요청 및 응답 지원.
현대 C ++를 사용합니다 (11/14)
비동기지지
HTTP/2 지원
여기에서 사용할 수 있습니다.
경고
Crow v0.3을 사용하는 경우
#define CROW_MAIN
하나의 소스 파일 중 하나에 넣어야합니다.
#include "crow.h"int main () { Crow :: SimpleApp App; Crow_route (App, "/") ([] () {return "Hello World"; }); app.port (18080) .multithreaded (). run (); }
crow_route (앱, "/json") ([] { crow :: json :: wvalue x ({{ "message", "hello, world!"}}); x [ "message2"] = "Hello, World .. Again!"; return x; });
crow_route (앱, "/hello/<int>") ([] (int count) {if (count> 100) return crow :: 응답 (400); std :: Ostringstream OS; OS << count << "맥주 병!"; return crow :: 응답 (os.str ()); });
처리 시간에 핸들러 인수 유형 확인
// 메시지와 함께 오류를 컴파일하는 "핸들러 유형은 URL 매개 변수와 일치하지 않습니다"Crow_route (app, "/other/<int>") ([] (int a, int b) {return crow :: 응답 (500); });
crow_route (앱, "/add_json") .methods ( "Post"_Method) ([] (const crow :: request & req) {auto x = crow :: json :: load (req.body); if (! x) crow :: 응답 (crow :: status :: bad_request); // Crow :: 응답 (400) int sum = x [ "a"]. i ()+x [ "b"]. i (); std :: Ostringstream OS; os << sum; return crow :: 응답 {os.str ()}; });
더 많은 예가 여기에서 찾을 수 있습니다.
여기에서 사용할 수 있습니다.
CrowCPP/Crow는 IPKN/Crow를 기반으로 한 프로젝트입니다. CrowCPP, 회원 또는이 프로젝트는 어떤 식 으로든 IPKN (Jaeseung HA)과 관련이 있거나 지원되지 않았습니다. 우리는 BSD-3 조항 라이센스에 따라 IPKN/Crow의 소스 코드를 사용하고 때로는 GitHub 저장소에서 이용할 수있는 공개 의견을 나타냅니다. 그러나 우리는 CrowCPP 또는 CrowCPP/Crow와 관련하여 IPKN (jaeseung ha)과 연락하거나 접촉한다고 주장하지 않습니다.
Crow는 다음 라이브러리를 소스에 통합했습니다.
http-parser (used for converting http strings to crow::request objects) https://github.com/nodejs/http-parser http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright Igor Sysoev. Additional changes are licensed under the same terms as NGINX and copyright Joyent, Inc. and other Node contributors. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------- qs_parse (used for reading query string parameters) https://github.com/bartgrantham/qs_parse Copyright (c) 2010 Bart Grantham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. --------------------------------------------------------------------------- TinySHA1 (used during the websocket handshake, not for security) https://github.com/mohaps/TinySHA1 TinySHA1 - a header only implementation of the SHA1 algorithm. Based on the implementation in boost::uuid::details Copyright (c) 2012-22 SAURAV MOHAPATRA [email protected] Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --------------------------------------------------------------------------- Catch2 (used only in unit tests, not part of the actual framework) https://github.com/catchorg/Catch2 Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.