mirror of
https://codeberg.org/tiff/goload.git
synced 2025-01-31 05:59:15 +00:00
37 lines
517 B
Go
37 lines
517 B
Go
|
package server
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"net/http"
|
||
|
"net/http/httputil"
|
||
|
"os"
|
||
|
// "strconv"
|
||
|
"sync"
|
||
|
"time"
|
||
|
|
||
|
_ "github.com/joho/godotenv/autoload"
|
||
|
)
|
||
|
//
|
||
|
// type Server struct {
|
||
|
// port int
|
||
|
// }
|
||
|
//
|
||
|
type Backend struct {
|
||
|
URL *url.URL
|
||
|
Alive bool
|
||
|
mux sync.RWMutex
|
||
|
ReverseProxy *httputil.ReverseProxy
|
||
|
}
|
||
|
|
||
|
type SeverPool struct {
|
||
|
backends []*Backend
|
||
|
current uint64
|
||
|
}
|
||
|
|
||
|
u, _ := url.Parse("http://localhost:8080")
|
||
|
rp := httputil.NewSingleHostReverseProxy(u)
|
||
|
|
||
|
http.HandlerFunc(rp.ServeHTTP)
|
||
|
|
||
|
|