Skip to content

Commit 5f210d4

Browse files
committed
docs: improve documentation and testing across multiple modules
- Add usage comments for DefaultHeaderTransport in client.go - Add args and returns comments for IsCommandAvailable function in util.go Signed-off-by: appleboy <[email protected]>
1 parent 478b792 commit 5f210d4

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

provider/openai/client.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ type DefaultHeaderTransport struct {
1414
// RoundTrip implements the http.RoundTripper interface.
1515
// It adds the headers from DefaultHeaderTransport to the request before sending it.
1616
// Usage:
17-
// transport := &DefaultHeaderTransport{
18-
// Origin: http.DefaultTransport,
19-
// Header: http.Header{
20-
// "Authorization": {"Bearer token"},
21-
// },
22-
// }
23-
// client := &http.Client{Transport: transport}
24-
// resp, err := client.Get("https://example.com")
17+
//
18+
// transport := &DefaultHeaderTransport{
19+
// Origin: http.DefaultTransport,
20+
// Header: http.Header{
21+
// "Authorization": {"Bearer token"},
22+
// },
23+
// }
24+
// client := &http.Client{Transport: transport}
25+
// resp, err := client.Get("https://example.com")
2526
func (t *DefaultHeaderTransport) RoundTrip(req *http.Request) (*http.Response, error) {
2627
for key, values := range t.Header {
2728
for _, value := range values {
@@ -35,9 +36,10 @@ func (t *DefaultHeaderTransport) RoundTrip(req *http.Request) (*http.Response, e
3536
// Each header in the slice should be in the format "key=value".
3637
// If a header is not in the correct format, it is skipped.
3738
// Usage:
38-
// headers := []string{"Authorization=Bearer token", "Content-Type=application/json"}
39-
// httpHeaders := NewHeaders(headers)
40-
// fmt.Println(httpHeaders.Get("Authorization")) // Output: Bearer token
39+
//
40+
// headers := []string{"Authorization=Bearer token", "Content-Type=application/json"}
41+
// httpHeaders := NewHeaders(headers)
42+
// fmt.Println(httpHeaders.Get("Authorization")) // Output: Bearer token
4143
func NewHeaders(headers []string) http.Header {
4244
h := make(http.Header)
4345
for _, header := range headers {

util/util.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ func IsCommandAvailable(cmd string) bool {
1919
// The resulting map contains the keys and values from the input slice.
2020
//
2121
// Args:
22-
// args ([]string): A slice of strings where each string is in the format "key=value".
22+
//
23+
// args ([]string): A slice of strings where each string is in the format "key=value".
2324
//
2425
// Returns:
25-
// Data: A map where the keys and values are derived from the input slice.
26+
//
27+
// Data: A map where the keys and values are derived from the input slice.
2628
func ConvertToMap(args []string) Data {
2729
m := make(Data)
2830
for _, arg := range args {

0 commit comments

Comments
 (0)