mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
use strings.Contains instead of strings.Index
This commit is contained in:
parent
10cd6053bc
commit
d117e31993
@ -37,7 +37,7 @@ func (mw *mockWriter) Reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mw *mockWriter) Contains(text string) bool {
|
func (mw *mockWriter) Contains(text string) bool {
|
||||||
return strings.Index(mw.builder.String(), text) > -1
|
return strings.Contains(mw.builder.String(), text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileLineFileMode(t *testing.T) {
|
func TestFileLineFileMode(t *testing.T) {
|
||||||
|
@ -39,7 +39,7 @@ func Parse(r *http.Request, v interface{}) error {
|
|||||||
|
|
||||||
// Parses the form request.
|
// Parses the form request.
|
||||||
func ParseForm(r *http.Request, v interface{}) error {
|
func ParseForm(r *http.Request, v interface{}) error {
|
||||||
if strings.Index(r.Header.Get(ContentType), multipartFormData) != -1 {
|
if strings.Contains(r.Header.Get(ContentType), multipartFormData) {
|
||||||
if err := r.ParseMultipartForm(maxMemory); err != nil {
|
if err := r.ParseMultipartForm(maxMemory); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -107,5 +107,5 @@ func ParsePath(r *http.Request, v interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func withJsonBody(r *http.Request) bool {
|
func withJsonBody(r *http.Request) bool {
|
||||||
return r.ContentLength > 0 && strings.Index(r.Header.Get(ContentType), ApplicationJson) != -1
|
return r.ContentLength > 0 && strings.Contains(r.Header.Get(ContentType), ApplicationJson)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user