sample.cc 551 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // sample.cc
  3. //
  4. // Copyright (c) 2012 Yuji Hirose. All rights reserved.
  5. // The Boost Software License 1.0
  6. //
  7. #include <httpsvrkit.h>
  8. #include <cstdio>
  9. using namespace httpsvrkit;
  10. int main(void)
  11. {
  12. const char* hi = "/hi";
  13. HTTP_SERVER("localhost", 1234) {
  14. GET("/", {
  15. res.set_redirect(hi);
  16. });
  17. GET("/hi", {
  18. res.set_content("Hello World!");
  19. });
  20. GET("/dump", {
  21. res.set_content(dump_request(cxt));
  22. });
  23. }
  24. }
  25. // vim: et ts=4 sw=4 cin cino={1s ff=unix