|
@@ -10,6 +10,7 @@ import (
|
|
|
|
|
|
func main() {
|
|
|
serverPort := 12345
|
|
|
+ path := ""
|
|
|
if len(os.Args) > 1 {
|
|
|
for k, v := range os.Args {
|
|
|
if k == 0 {
|
|
@@ -18,6 +19,7 @@ func main() {
|
|
|
arg := strings.TrimSpace(v)
|
|
|
hasPortL := strings.HasPrefix(arg, "--port=")
|
|
|
hasPortS := strings.HasPrefix(arg, "-p=")
|
|
|
+ hasPath := strings.HasPrefix(arg, "--path=")
|
|
|
if hasPortL {
|
|
|
i, err := strconv.ParseInt(strings.ReplaceAll(arg, "--port=", ""), 10, 32)
|
|
|
if err == nil {
|
|
@@ -32,18 +34,28 @@ func main() {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
+ if hasPath {
|
|
|
+ path = strings.ReplaceAll(arg, "--path=", "")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- http.HandleFunc("/", indexHandler)
|
|
|
- http.HandleFunc("/jrebel/leases", jrebelLeasesHandler)
|
|
|
- http.HandleFunc("/jrebel/leases/1", jrebelLeases1Handler)
|
|
|
- http.HandleFunc("/agent/leases", jrebelLeasesHandler)
|
|
|
- http.HandleFunc("/agent/leases/1", jrebelLeases1Handler)
|
|
|
- http.HandleFunc("/jrebel/validate-connection", jrebelValidateHandler)
|
|
|
- http.HandleFunc("/rpc/ping.action", pingHandler)
|
|
|
- http.HandleFunc("/rpc/obtainTicket.action", obtainTicketHandler)
|
|
|
- http.HandleFunc("/rpc/releaseTicket.action", releaseTicketHandler)
|
|
|
+ if strings.HasSuffix(path, "/") {
|
|
|
+ path = strings.TrimSuffix(path, "/")
|
|
|
+ }
|
|
|
+ if len(path) > 0 && !strings.HasPrefix(path, "/") {
|
|
|
+ path = fmt.Sprintf("/%s", path)
|
|
|
+ }
|
|
|
+
|
|
|
+ http.HandleFunc(path, indexHandler)
|
|
|
+ http.HandleFunc(fmt.Sprintf("%s/jrebel/leases", path), jrebelLeasesHandler)
|
|
|
+ http.HandleFunc(fmt.Sprintf("%s/jrebel/leases/1", path), jrebelLeases1Handler)
|
|
|
+ http.HandleFunc(fmt.Sprintf("%s/agent/leases", path), jrebelLeasesHandler)
|
|
|
+ http.HandleFunc(fmt.Sprintf("%s/agent/leases/1", path), jrebelLeases1Handler)
|
|
|
+ http.HandleFunc(fmt.Sprintf("%s/jrebel/validate-connection", path), jrebelValidateHandler)
|
|
|
+ http.HandleFunc(fmt.Sprintf("%s/rpc/ping.action", path), pingHandler)
|
|
|
+ http.HandleFunc(fmt.Sprintf("%s/rpc/obtainTicket.action", path), obtainTicketHandler)
|
|
|
+ http.HandleFunc(fmt.Sprintf("%s/rpc/releaseTicket.action", path), releaseTicketHandler)
|
|
|
|
|
|
fmt.Printf("start server with port = %d\n", serverPort)
|
|
|
|