getting_started.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. if [ ! -x bin/httpd -o ! -x bin/curl ]; then
  3. make clean
  4. make httpd curl
  5. fi
  6. processes=$(ps aux | grep -v grep | grep httpd | wc -l)
  7. if [ $processes -lt 1 ]; then
  8. bin/httpd -s restart -d
  9. fi
  10. ps aux | grep httpd
  11. PS4="\033[32m+ \033[0m"
  12. set -x
  13. # http web service
  14. read -n1
  15. bin/curl -v localhost:8080
  16. # http indexof service
  17. read -n1
  18. bin/curl -v localhost:8080/downloads/
  19. # http api service
  20. read -n1
  21. bin/curl -v localhost:8080/ping
  22. read -n1
  23. bin/curl -v localhost:8080/echo -d "hello,world!"
  24. read -n1
  25. bin/curl -v localhost:8080/query?page_no=1\&page_size=10
  26. read -n1
  27. bin/curl -v localhost:8080/kv -H "Content-Type:application/x-www-form-urlencoded" -d 'user=admin&pswd=123456'
  28. read -n1
  29. bin/curl -v localhost:8080/json -H "Content-Type:application/json" -d '{"user":"admin","pswd":"123456"}'
  30. read -n1
  31. bin/curl -v localhost:8080/form -F "user=admin pswd=123456"
  32. read -n1
  33. bin/curl -v localhost:8080/upload -F "file=@LICENSE"
  34. read -n1
  35. bin/curl -v localhost:8080/test -H "Content-Type:application/x-www-form-urlencoded" -d 'bool=1&int=123&float=3.14&string=hello'
  36. read -n1
  37. bin/curl -v localhost:8080/test -H "Content-Type:application/json" -d '{"bool":true,"int":123,"float":3.14,"string":"hello"}'
  38. read -n1
  39. bin/curl -v localhost:8080/test -F 'bool=1 int=123 float=3.14 string=hello'
  40. # RESTful API: /group/:group_name/user/:user_id
  41. read -n1
  42. bin/curl -v -X DELETE localhost:8080/group/test/user/123
  43. # see logs
  44. read -n1
  45. tail -n 100 logs/httpd*.log