Merge pull request #486 from codingsince1985/master

remove duplicated paragraph
This commit is contained in:
astaxie
2015-06-24 20:57:41 +08:00

View File

@@ -131,9 +131,7 @@ Go handles errors and checks the return values of functions in a C-like fashion,
}
}
The above example demonstrate access to data and template call has detected error when an error occurs , call a unified handler http.Error, returns a 500 error code to the client , and display the corresponding error data. But when more and more HandleFunc join, so error-handling logic code will be more and more, in fact, we can customize the router to reduce code ( refer to realize the idea of the third chapter of HTTP Detailed) .
The above function is an example of getting data and handling an error when it occurs by calling a unified error processing function called `http.Error`. In this case, it will return an Internal Error 500 code to the client, and display the corresponding error data. Even using this method however, when more and more `HandleFunc`'s are needed, the error-handling logic can still become quite bloated. An alternative approach would be to customize our router to handle errors by default:
The above example demonstrate access to data and template call has detected error when an error occurs , call a unified handler http.Error, returns a 500 error code to the client , and display the corresponding error data. But when more and more HandleFunc join, so error-handling logic code will be more and more, in fact, we can customize the router to reduce code (refer to realize the idea of the third chapter of HTTP Detailed).
type appHandler func(http.ResponseWriter, *http.Request) error