An HTTP request value stores the method, URL, host, and path before any network call is made.

Build Request

build_request.go
package main

import "fmt"

func splitEndpoint(endpoint string) (string, string) {
	rest := endpoint[len("https://"):]
	slashIndex := 0
	for index, letter := range rest {
		if letter == '/' {
			slashIndex = index
			break
		}
	}
	host := rest[:slashIndex]
	path := rest[slashIndex:]
	return host, path
}

func main() {
	var endpoint = 
	host, path := splitEndpoint(endpoint)

	method := "GET"
	fmt.Println("method=", method)
	fmt.Println("host=", host)
	fmt.Println("path=", path)
}
package main

import "fmt"

func splitEndpoint(endpoint string) (string, string) {
	rest := endpoint[len("https://"):]
	slashIndex := 0
	for index, letter := range rest {
		if letter == '/' {
			slashIndex = index
			break
		}
	}
	host := rest[:slashIndex]
	path := rest[slashIndex:]
	return host, path
}

func main() {
	var endpoint = 
	host, path := splitEndpoint(endpoint)

	method := "GET"
	fmt.Println("method=", method)
	fmt.Println("host=", host)
	fmt.Println("path=", path)
}
package main

import "fmt"

func splitEndpoint(endpoint string) (string, string) {
	rest := endpoint[len("https://"):]
	slashIndex := 0
	for index, letter := range rest {
		if letter == '/' {
			slashIndex = index
			break
		}
	}
	host := rest[:slashIndex]
	path := rest[slashIndex:]
	return host, path
}

func main() {
	var endpoint = 
	host, path := splitEndpoint(endpoint)

	method := "GET"
	fmt.Println("method=", method)
	fmt.Println("host=", host)
	fmt.Println("path=", path)
}
request object A client prepares a method, host, and path before any network call is made.