cppcms 1.0.5
Closes Homebrew/homebrew#41871. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
19a138846e
commit
04a773ec0a
1 changed files with 86 additions and 0 deletions
86
Formula/cppcms.rb
Normal file
86
Formula/cppcms.rb
Normal file
|
@ -0,0 +1,86 @@
|
|||
class Cppcms < Formula
|
||||
desc "A Free High Performance Web Development Framework"
|
||||
homepage "http://cppcms.com/wikipp/en/page/main"
|
||||
url "https://downloads.sourceforge.net/project/cppcms/cppcms/1.0.5/cppcms-1.0.5.tar.bz2"
|
||||
sha256 "84b685977bca97c3e997497f227bd5906adb80555066d811a7046b01c2f51865"
|
||||
|
||||
depends_on "cmake" => :build
|
||||
depends_on "pcre"
|
||||
depends_on "openssl"
|
||||
needs :cxx11
|
||||
|
||||
def install
|
||||
ENV.cxx11
|
||||
system "cmake", *std_cmake_args
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"hello.cpp").write <<-EOS.undent
|
||||
#include <cppcms/application.h>
|
||||
#include <cppcms/applications_pool.h>
|
||||
#include <cppcms/service.h>
|
||||
#include <cppcms/http_response.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class hello : public cppcms::application {
|
||||
public:
|
||||
hello(cppcms::service& srv): cppcms::application(srv) {}
|
||||
virtual void main(std::string url);
|
||||
};
|
||||
|
||||
void hello::main(std::string /*url*/)
|
||||
{
|
||||
response().out() <<
|
||||
"<html>\\n"
|
||||
"<body>\\n"
|
||||
" <h1>Hello World</h1>\\n"
|
||||
"</body>\\n"
|
||||
"</html>\\n";
|
||||
}
|
||||
|
||||
int main(int argc,char ** argv)
|
||||
{
|
||||
try {
|
||||
cppcms::service srv(argc,argv);
|
||||
srv.applications_pool().mount(
|
||||
cppcms::applications_factory<hello>()
|
||||
);
|
||||
srv.run();
|
||||
return 0;
|
||||
}
|
||||
catch(std::exception const &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
EOS
|
||||
|
||||
(testpath/"config.json").write <<-EOS.undent
|
||||
{
|
||||
"service" : {
|
||||
"api" : "http",
|
||||
"port" : 8080,
|
||||
"worker_threads": 1
|
||||
},
|
||||
"daemon" : {
|
||||
"enable" : false
|
||||
},
|
||||
"http" : {
|
||||
"script_names" : [ "/hello" ]
|
||||
}
|
||||
}
|
||||
EOS
|
||||
system ENV.cxx, "-o", "hello", "-std=c++11", "-stdlib=libc++", "-lc++", "-lcppcms", "hello.cpp"
|
||||
pid = fork { exec "./hello", "-c", "config.json" }
|
||||
|
||||
sleep 1 # grace time for server start
|
||||
begin
|
||||
assert_match /Hello World/, shell_output("curl http://127.0.0.1:8080/hello")
|
||||
ensure
|
||||
Process.kill 9, pid
|
||||
Process.wait pid
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue