MCPcopy Create free account
hub / github.com/gavv/httpexpect / WithQueryEncoder

Method WithQueryEncoder

request.go:1377–1395  ·  view source on GitHub ↗

WithQueryEncoder forces use of specific encoder or encoder mode when an object is converted to query string in WithQueryObject(). See documentation for QueryEncoder enum for evailable encoders. In particular, you can use it to force ajg/form encoder for structs instead of google/go-querystring, or

(encoder QueryEncoder)

Source from the content-addressed store, hash-verified

1375// req.WithQueryObject(map[string]interface{}{"a": 0, "b": 0})
1376// // URL is now http://example.com/path?a=0&b=0
1377func (r *Request) WithQueryEncoder(encoder QueryEncoder) *Request {
1378 opChain := r.chain.enter("WithQueryEncoder()")
1379 defer opChain.leave()
1380
1381 r.mu.Lock()
1382 defer r.mu.Unlock()
1383
1384 if opChain.failed() {
1385 return r
1386 }
1387
1388 if !r.checkOrder(opChain, "WithQueryEncoder()") {
1389 return r
1390 }
1391
1392 r.queryEncoder = encoder
1393
1394 return r
1395}
1396
1397func selectQueryEncoder(object interface{}) QueryEncoder {
1398 value := reflect.Indirect(reflect.ValueOf(object))

Callers 3

TestRequest_FailedChainFunction · 0.80
TestRequest_URLQueryFunction · 0.80
TestRequest_OrderFunction · 0.80

Calls 6

checkOrderMethod · 0.95
enterMethod · 0.80
leaveMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
failedMethod · 0.80

Tested by 3

TestRequest_FailedChainFunction · 0.64
TestRequest_URLQueryFunction · 0.64
TestRequest_OrderFunction · 0.64