 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Example ¶
package main
import (
	"log"
	"net/http"
	http_ "github.com/searKing/golang/go/net/http"
	"github.com/searKing/golang/go/net/http/httphost"
	_ "github.com/searKing/golang/go/net/resolver/passthrough"
)
func main() {
	req, _ := http.NewRequest("GET", "http://example.com", nil)
	proxy := &httphost.Host{
		HostTarget: "127.0.0.1",
	}
	req = req.WithContext(httphost.WithHost(req.Context(), proxy))
	err := http_.HostFuncFromContext(req)
	if err != nil {
		log.Fatal(err)
	}
	_, err = http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Host ¶
type Host struct {
	// HostTarget is as like gRPC Naming for host service discovery, with Host in TargetUrl replaced if not empty.
	HostTarget string
	// resolve HostTarget to host and replace host if HostTarget resolved
	ReplaceHostInRequest bool
	// HostTargetAddrResolved is the host's addr resolved and picked from resolver.
	HostTargetAddrResolved resolver.Address
}
    Host specifies TargetUrl and HostTarget to return a dynamic host.
func ContextHost ¶
ContextHost returns the Host associated with the provided context. If none, it returns nil.
 Click to show internal directories. 
   Click to hide internal directories.