package httpx

import (
	

	
)

// Dump enables req's request-level dump output.
// @group Debugging
//
// Applies to individual requests only.
// Example: dump a single request
//
//	c := httpx.New()
//	_ = httpx.Get[string](c, "https://example.com", httpx.Dump())
func () OptionBuilder {
	return OptionBuilder{}.Dump()
}

func ( OptionBuilder) () OptionBuilder {
	return .add(requestOnly(func( *req.Request) {
		.EnableDump()
	}))
}

// DumpTo enables req's request-level dump output to a writer.
// @group Debugging
//
// Applies to individual requests only.
// Example: dump to a buffer
//
//	var buf bytes.Buffer
//	c := httpx.New()
//	_ = httpx.Get[string](c, "https://example.com", httpx.DumpTo(&buf))
func ( io.Writer) OptionBuilder {
	return OptionBuilder{}.DumpTo()
}

func ( OptionBuilder) ( io.Writer) OptionBuilder {
	return .add(requestOnly(func( *req.Request) {
		.EnableDumpTo()
	}))
}

// DumpToFile enables req's request-level dump output to a file path.
// @group Debugging
//
// Applies to individual requests only.
// Example: dump to a file
//
//	c := httpx.New()
//	_ = httpx.Get[string](c, "https://example.com", httpx.DumpToFile("httpx.dump"))
func ( string) OptionBuilder {
	return OptionBuilder{}.DumpToFile()
}

func ( OptionBuilder) ( string) OptionBuilder {
	return .add(requestOnly(func( *req.Request) {
		.EnableDumpToFile()
	}))
}

// DumpAll enables req's client-level dump output for all requests.
// @group Debugging
//
// Applies to the client configuration only.
// Example: dump every request and response
//
//	c := httpx.New(httpx.DumpAll())
//	_ = c
func () OptionBuilder {
	return OptionBuilder{}.DumpAll()
}

func ( OptionBuilder) () OptionBuilder {
	return .add(clientOnly(func( *Client) {
		.req.EnableDumpAll()
	}))
}

// DumpEachRequest enables request-level dumps for each request on the client.
// @group Debugging
//
// Applies to the client configuration only.
// Example: dump each request as it is sent
//
//	c := httpx.New(httpx.DumpEachRequest())
//	_ = c
func () OptionBuilder {
	return OptionBuilder{}.DumpEachRequest()
}

func ( OptionBuilder) () OptionBuilder {
	return .add(clientOnly(func( *Client) {
		.req.EnableDumpEachRequest()
	}))
}

// DumpEachRequestTo enables request-level dumps for each request and writes them to the provided output.
// @group Debugging
//
// Applies to the client configuration only.
// Example: dump each request to a buffer
//
//	var buf bytes.Buffer
//	c := httpx.New(httpx.DumpEachRequestTo(&buf))
//	_ = httpx.Get[string](c, "https://example.com")
//	_ = buf.String()
func ( io.Writer) OptionBuilder {
	return OptionBuilder{}.DumpEachRequestTo()
}

func ( OptionBuilder) ( io.Writer) OptionBuilder {
	return .add(clientOnly(func( *Client) {
		if  == nil {
			return
		}
		.req.EnableDumpEachRequest()
		.req.OnAfterResponse(func( *req.Client,  *req.Response) error {
			if  == nil {
				return nil
			}
			_, _ = .Write([]byte(.Dump()))
			return nil
		})
	}))
}

// Trace enables req's request-level trace output.
// @group Debugging
//
// Applies to individual requests only.
// Example: trace a single request
//
//	c := httpx.New()
//	_ = httpx.Get[string](c, "https://example.com", httpx.Trace())
func () OptionBuilder {
	return OptionBuilder{}.Trace()
}

func ( OptionBuilder) () OptionBuilder {
	return .add(requestOnly(func( *req.Request) {
		.EnableTrace()
	}))
}

// TraceAll enables req's client-level trace output for all requests.
// @group Debugging
//
// Applies to the client configuration only.
// Example: trace all requests
//
//	c := httpx.New(httpx.TraceAll())
//	_ = c
func () OptionBuilder {
	return OptionBuilder{}.TraceAll()
}

func ( OptionBuilder) () OptionBuilder {
	return .add(clientOnly(func( *Client) {
		.req.EnableTraceAll()
	}))
}