handler.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. }
  23. func loginHandler(w http.ResponseWriter, r *http.Request) {
  24. w.Header().Set("Content-Type", "application/json")
  25. f_login(w, r)
  26. }
  27. func cookieLoginHandler(w http.ResponseWriter, r *http.Request) {
  28. w.Header().Set("Content-Type", "application/json")
  29. f_cookieLogin(w, r)
  30. }
  31. func registerHandler(w http.ResponseWriter, r *http.Request) {
  32. w.Header().Set("Content-Type", "application/json")
  33. f_register(w, r)
  34. }
  35. func getUserInfoHandler(w http.ResponseWriter, r *http.Request) {
  36. w.Header().Set("Content-Type", "application/json")
  37. f_getUserInfo(w, r)
  38. }
  39. func setUrlHandler(w http.ResponseWriter, r *http.Request) {
  40. w.Header().Set("Content-Type", "application/json")
  41. f_setUrl(w, r)
  42. }
  43. func getUrlHandler(w http.ResponseWriter, r *http.Request) {
  44. w.Header().Set("Content-Type", "application/json")
  45. f_getUrl(w, r)
  46. }
  47. func setKeyHandler(w http.ResponseWriter, r *http.Request) {
  48. w.Header().Set("Content-Type", "application/json")
  49. f_setKey(w, r)
  50. }
  51. func getKeyHandler(w http.ResponseWriter, r *http.Request) {
  52. w.Header().Set("Content-Type", "application/json")
  53. f_getKey(w, r)
  54. }
  55. func getLogHandler(w http.ResponseWriter, r *http.Request) {
  56. w.Header().Set("Content-Type", "application/json")
  57. f_getLog(w, r)
  58. }
  59. func getLogAdminHandler(w http.ResponseWriter, r *http.Request) {
  60. w.Header().Set("Content-Type", "application/json")
  61. f_getLogAdmin(w, r)
  62. }
  63. func getLogDetailsHandler(w http.ResponseWriter, r *http.Request) {
  64. w.Header().Set("Content-Type", "application/json")
  65. f_getLogDetails(w, r)
  66. }