mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
change 404 not found to json error
This commit is contained in:
parent
98d6dc0dd4
commit
aa3f0b3a2a
@ -103,7 +103,8 @@ func dispatch(c Command, w *http.ResponseWriter, req *http.Request, client bool)
|
|||||||
if raftServer.State() == "leader" {
|
if raftServer.State() == "leader" {
|
||||||
if body, err := raftServer.Do(c); err != nil {
|
if body, err := raftServer.Do(c); err != nil {
|
||||||
if _, ok := err.(store.NotFoundError); ok {
|
if _, ok := err.(store.NotFoundError); ok {
|
||||||
http.NotFound((*w), req)
|
(*w).WriteHeader(http.StatusNotFound)
|
||||||
|
(*w).Write(newJsonError(100, err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +130,8 @@ func dispatch(c Command, w *http.ResponseWriter, req *http.Request, client bool)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
if body == nil {
|
if body == nil {
|
||||||
http.NotFound((*w), req)
|
(*w).WriteHeader(http.StatusNotFound)
|
||||||
|
(*w).Write(newJsonError(100, err.Error()))
|
||||||
} else {
|
} else {
|
||||||
body, ok := body.([]byte)
|
body, ok := body.([]byte)
|
||||||
// this should not happen
|
// this should not happen
|
||||||
@ -235,7 +237,8 @@ func GetHttpHandler(w *http.ResponseWriter, req *http.Request) {
|
|||||||
if body, err := command.Apply(raftServer); err != nil {
|
if body, err := command.Apply(raftServer); err != nil {
|
||||||
|
|
||||||
if _, ok := err.(store.NotFoundError); ok {
|
if _, ok := err.(store.NotFoundError); ok {
|
||||||
http.NotFound((*w), req)
|
(*w).WriteHeader(http.StatusNotFound)
|
||||||
|
(*w).Write(newJsonError(100, err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
etcd.go
2
etcd.go
@ -178,7 +178,7 @@ func main() {
|
|||||||
signal.Notify(c, os.Interrupt)
|
signal.Notify(c, os.Interrupt)
|
||||||
go func() {
|
go func() {
|
||||||
for sig := range c {
|
for sig := range c {
|
||||||
log.Printf("captured %v, stopping profiler and exiting..", sig)
|
fmt.Printf("captured %v, stopping profiler and exiting..", sig)
|
||||||
pprof.StopCPUProfile()
|
pprof.StopCPUProfile()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user