摘要:        
package main import ( "fmt" "sort" ) type ServerSlice []Server type Server struct { Weight int } //只要实现了下面三个方法就可以传入sort方法使用 func (p ServerSlice) Len() int { return len(p) } fu...    阅读全文
posted @ 2019-12-19 22:49
离地最远的星
阅读(398)
评论(0)
推荐(0)
        
            
        
        
摘要:        
package util import ( "fmt" "hash/crc32" "math/rand" "sort" "time" ) type HttpServer struct { //目标server类 Host string Weight int CWeight int //当前权重 ...    阅读全文
posted @ 2019-12-19 22:48
离地最远的星
阅读(1106)
评论(0)
推荐(0)
        
            
        
        
摘要:        
package main import ( "log" "net/http" "net/http/httputil" "net/url" "os" "os/signal" "regexp" "反向代理/util" ) type ProxyHandler struct { } func (*ProxyHandler) ServeH...    阅读全文
posted @ 2019-12-19 22:47
离地最远的星
阅读(451)
评论(0)
推荐(0)
        
            
        
        
摘要:        
来自为知笔记(Wiz)    阅读全文
posted @ 2019-12-19 22:46
离地最远的星
阅读(212)
评论(0)
推荐(0)
        
            
        
        
摘要:        
package util import ( "fmt" "hash/crc32" "math/rand" "time" ) type HttpServer struct { //目标server类 Host string Weight int } func NewHttpServer(host string, weight int) *Ht...    阅读全文
posted @ 2019-12-19 22:45
离地最远的星
阅读(303)
评论(0)
推荐(0)
        
            
        
        
摘要:        
func (this *LoadBalance) RoundRobinByWeight3() *HttpServer { //平滑加权轮询 for _, s := range this.Servers { s.CWeight = s.CWeight + s.Weight } sort.Sort(this.Servers) max := this....    阅读全文
posted @ 2019-12-19 22:44
离地最远的星
阅读(213)
评论(0)
推荐(0)
        
            
        
        
摘要:        
来自为知笔记(Wiz)    阅读全文
posted @ 2019-12-19 22:43
离地最远的星
阅读(290)
评论(0)
推荐(0)
        
            
        
        
摘要:        
package util import ( "math/rand" "time" ) type HttpServer struct { //目标server类 Host string } func NewHttpServer(host string) *HttpServer { return &HttpServer{Host: host} } type Lo...    阅读全文
posted @ 2019-12-19 22:41
离地最远的星
阅读(249)
评论(0)
推荐(0)
        
            
        
        
摘要:        
Go实现 在头里设置WWW-Authenticate 返回401 func (webhandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) { writer.Header().Set("WWW-Authenticate", `Basic realm="您必须输入用户名和密码"`) writer...    阅读全文
posted @ 2019-12-19 22:41
离地最远的星
阅读(182)
评论(0)
推荐(0)
        
            
        
        
摘要:        
package main import ( "io/ioutil" "log" "net/http" "os" "os/signal" ) type ProxyHandler struct { } func (*ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { d...    阅读全文
posted @ 2019-12-19 22:40
离地最远的星
阅读(122)
评论(0)
推荐(0)
        
 
                     
                    
                 
                    
                
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号