mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
fix some types on errors and form
Signed-off-by: kaiwentan <kaiwentan@harmonycloud.cn>
This commit is contained in:
parent
09e99ef1fc
commit
ac9c47e26f
3 changed files with 3 additions and 3 deletions
|
@ -16,7 +16,7 @@ func (e apiError) HTTPErrorStatusCode() int {
|
||||||
|
|
||||||
// NewErrorWithStatusCode allows you to associate
|
// NewErrorWithStatusCode allows you to associate
|
||||||
// a specific HTTP Status Code to an error.
|
// a specific HTTP Status Code to an error.
|
||||||
// The Server will take that code and set
|
// The server will take that code and set
|
||||||
// it as the response status.
|
// it as the response status.
|
||||||
func NewErrorWithStatusCode(err error, code int) error {
|
func NewErrorWithStatusCode(err error, code int) error {
|
||||||
return apiError{err, code}
|
return apiError{err, code}
|
||||||
|
|
|
@ -28,7 +28,7 @@ type inputValidationError interface {
|
||||||
IsValidationError() bool
|
IsValidationError() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHTTPErrorStatusCode retrieves status code from error message
|
// GetHTTPErrorStatusCode retrieves status code from error message.
|
||||||
func GetHTTPErrorStatusCode(err error) int {
|
func GetHTTPErrorStatusCode(err error) int {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logrus.WithFields(logrus.Fields{"error": err}).Error("unexpected HTTP error handling")
|
logrus.WithFields(logrus.Fields{"error": err}).Error("unexpected HTTP error handling")
|
||||||
|
|
|
@ -15,7 +15,7 @@ func BoolValue(r *http.Request, k string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// BoolValueOrDefault returns the default bool passed if the query param is
|
// BoolValueOrDefault returns the default bool passed if the query param is
|
||||||
// missing, otherwise it's just a proxy to boolValue above
|
// missing, otherwise it's just a proxy to boolValue above.
|
||||||
func BoolValueOrDefault(r *http.Request, k string, d bool) bool {
|
func BoolValueOrDefault(r *http.Request, k string, d bool) bool {
|
||||||
if _, ok := r.Form[k]; !ok {
|
if _, ok := r.Form[k]; !ok {
|
||||||
return d
|
return d
|
||||||
|
|
Loading…
Reference in a new issue