http

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var NewRequest = http.NewRequest
View Source
var Transporter *http.Transport

Functions

func Client

func Client(timeout time.Duration) http.Client
Example
package main

import (
	"fmt"
	"io"
	"time"

	"simonwaldherr.de/go/golibs/http"
)

func main() {
	client := http.Client(time.Second * 15)
	resp, err := client.Get("http://localhost:8081/hello")

	if err != nil {
		fmt.Println(err)
	}

	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(string(body))

}
Output:

hello world

func GetString

func GetString(url string) (string, error)
Example
package main

import (
	"fmt"

	"simonwaldherr.de/go/golibs/http"
)

func main() {
	resp, err := http.GetString("http://localhost:8081/hello")

	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(resp)

}
Output:

hello world

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL