handler.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package main
  2. import (
  3. "net/http"
  4. )
  5. func init() {
  6. http.Handle("/", http.FileServer(http.Dir("/root/go/src/iaun.cn/sendpackage/static/")))
  7. // user+auth
  8. http.HandleFunc("/api/auth/login", loginHandler)
  9. http.HandleFunc("/api/auth/login/cookie", cookieLoginHandler)
  10. http.HandleFunc("/api/auth/register", registerHandler)
  11. http.HandleFunc("/api/user/get", getUserInfoHandler)
  12. // url
  13. http.HandleFunc("/api/url/set", setUrlHandler)
  14. http.HandleFunc("/api/url/get", getUrlHandler)
  15. // ak sk
  16. http.HandleFunc("/api/key/set", setKeyHandler)
  17. http.HandleFunc("/api/key/get", getKeyHandler)
  18. // log
  19. http.HandleFunc("/api/log/get", getLogHandler)
  20. // http.HandleFunc("/api/log/get/admin", getLogAdminHandler)
  21. http.HandleFunc("/api/log/get/details", getLogDetailsHandler)
  22. // admin
  23. http.HandleFunc("/api/admin/login", adminLoginHandler)
  24. http.HandleFunc("/api/admin/get", adminGetDataHandler)
  25. http.HandleFunc("/api/admin/login/cookie", adminCookieLoginHandler)
  26. http.HandleFunc("/api/admin/key/get", adminGetKeyHandler)
  27. }
  28. func loginHandler(w http.ResponseWriter, r *http.Request) {
  29. w.Header().Set("Content-Type", "application/json")
  30. f_login(w, r)
  31. }
  32. func cookieLoginHandler(w http.ResponseWriter, r *http.Request) {
  33. w.Header().Set("Content-Type", "application/json")
  34. f_cookieLogin(w, r)
  35. }
  36. func registerHandler(w http.ResponseWriter, r *http.Request) {
  37. w.Header().Set("Content-Type", "application/json")
  38. f_register(w, r)
  39. }
  40. func getUserInfoHandler(w http.ResponseWriter, r *http.Request) {
  41. w.Header().Set("Content-Type", "application/json")
  42. f_getUserInfo(w, r)
  43. }
  44. func setUrlHandler(w http.ResponseWriter, r *http.Request) {
  45. w.Header().Set("Content-Type", "application/json")
  46. f_setUrl(w, r)
  47. }
  48. func getUrlHandler(w http.ResponseWriter, r *http.Request) {
  49. w.Header().Set("Content-Type", "application/json")
  50. f_getUrl(w, r)
  51. }
  52. func setKeyHandler(w http.ResponseWriter, r *http.Request) {
  53. w.Header().Set("Content-Type", "application/json")
  54. f_setKey(w, r)
  55. }
  56. func getKeyHandler(w http.ResponseWriter, r *http.Request) {
  57. w.Header().Set("Content-Type", "application/json")
  58. f_getKey(w, r)
  59. }
  60. func getLogHandler(w http.ResponseWriter, r *http.Request) {
  61. w.Header().Set("Content-Type", "application/json")
  62. f_getLog(w, r)
  63. }
  64. // func getLogAdminHandler(w http.ResponseWriter, r *http.Request) {
  65. // w.Header().Set("Content-Type", "application/json")
  66. // f_getLogAdmin(w, r)
  67. // }
  68. func getLogDetailsHandler(w http.ResponseWriter, r *http.Request) {
  69. w.Header().Set("Content-Type", "application/json")
  70. f_getLogDetails(w, r)
  71. }
  72. func adminLoginHandler(w http.ResponseWriter, r *http.Request) {
  73. w.Header().Set("Content-Type", "application/json")
  74. f_adminLogin(w, r)
  75. }
  76. func adminGetDataHandler(w http.ResponseWriter, r *http.Request) {
  77. w.Header().Set("Content-Type", "application/json")
  78. f_adminGetData(w, r)
  79. }
  80. func adminCookieLoginHandler(w http.ResponseWriter, r *http.Request) {
  81. w.Header().Set("Content-Type", "application/json")
  82. f_adminCookieLogin(w, r)
  83. }
  84. func adminGetKeyHandler(w http.ResponseWriter, r *http.Request) {
  85. w.Header().Set("Content-Type", "application/json")
  86. f_adminGetKey(w, r)
  87. }