removed repeated GetId functions using struct embedding

This commit is contained in:
2024-12-27 16:52:27 +09:00
parent f1572f9321
commit 9d266180e9
9 changed files with 175 additions and 134 deletions

View File

@@ -31,22 +31,24 @@ var xterm_css []byte
//go:embed xterm.html
var xterm_html []byte
type server_proxy_http_init struct {
type server_proxy struct {
s *Server
prefix string
id string
}
type server_proxy_http_init struct {
server_proxy
prefix string
}
type server_proxy_http_main struct {
s *Server
server_proxy
prefix string
id string
}
type server_proxy_xterm_file struct {
s *Server
server_proxy
file string
id string
}
// ------------------------------------
@@ -168,12 +170,12 @@ func mutate_proxy_req_headers(req *http.Request, newreq *http.Request, path_pref
return upgrade_required
}
// ------------------------------------
func (pxy *server_proxy_http_init) GetId() string {
func (pxy *server_proxy) GetId() string {
return pxy.id
}
// ------------------------------------
func (pxy *server_proxy_http_init) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int
@@ -364,10 +366,6 @@ func (pxy *server_proxy_http_main) req_to_proxy_url (req *http.Request, r *Serve
}
}
func (pxy *server_proxy_http_main) GetId() string {
return pxy.id
}
func (pxy *server_proxy_http_main) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var r *ServerRoute
@@ -489,10 +487,6 @@ type server_proxy_xterm_session_info struct {
RouteId string
}
func (pxy *server_proxy_xterm_file) GetId() string {
return pxy.id
}
func (pxy *server_proxy_xterm_file) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int