luat_httpsrv.h 609 B

123456789101112131415161718192021222324252627282930313233
  1. #include "luat_base.h"
  2. typedef struct luat_httpsrv_ctx
  3. {
  4. uint16_t port;
  5. uint16_t https;
  6. char static_path[32];
  7. int lua_ref_id;
  8. int server_fd;
  9. void* userdata;
  10. }luat_httpsrv_ctx_t;
  11. typedef struct http_code_str
  12. {
  13. int code;
  14. const char* msg;
  15. }http_code_str_t;
  16. static const http_code_str_t http_codes[] = {
  17. {200, "OK"},
  18. {302, "Found"},
  19. {400, "Bad Request"},
  20. {401, "Unauthorized"},
  21. {403, "Forbidden"},
  22. {404, "Not Found"},
  23. {500, "Internal Server Error"},
  24. {0, ""}
  25. };
  26. int luat_httpsrv_stop(int port);
  27. int luat_httpsrv_start(luat_httpsrv_ctx_t* ctx);