| 77 | } |
| 78 | |
| 79 | func (m *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 80 | log.LogInfof("URL[%v],remoteAddr[%v]", r.URL, r.RemoteAddr) |
| 81 | switch r.URL.Path { |
| 82 | case proto.ClientGetTicket: |
| 83 | m.getTicket(w, r) |
| 84 | case proto.AdminCreateKey: |
| 85 | fallthrough |
| 86 | case proto.AdminGetKey: |
| 87 | fallthrough |
| 88 | case proto.AdminDeleteKey: |
| 89 | fallthrough |
| 90 | case proto.AdminAddCaps: |
| 91 | fallthrough |
| 92 | case proto.AdminDeleteCaps: |
| 93 | fallthrough |
| 94 | case proto.AdminGetCaps: |
| 95 | m.apiAccessEntry(w, r) |
| 96 | case proto.AdminAddRaftNode: |
| 97 | fallthrough |
| 98 | case proto.AdminRemoveRaftNode: |
| 99 | m.raftNodeOp(w, r) |
| 100 | case proto.OSAddCaps: |
| 101 | fallthrough |
| 102 | case proto.OSDeleteCaps: |
| 103 | fallthrough |
| 104 | case proto.OSGetCaps: |
| 105 | m.osCapsOp(w, r) |
| 106 | default: |
| 107 | sendErrReply(w, r, &proto.HTTPAuthReply{Code: proto.ErrCodeParamError, Msg: "Invalid requst URL"}) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | func (m *Server) handleFunctions() { |
| 112 | http.HandleFunc(proto.ClientGetTicket, m.getTicket) |