@@ -25,7 +25,7 @@ import (
2525 "os/exec"
2626
2727 "github.com/golang/glog"
28- tb "github.com/presslabs/mysql-operator/cmd/mysql-helper/util"
28+ "github.com/presslabs/mysql-operator/cmd/mysql-helper/util"
2929)
3030
3131type server struct {
@@ -36,14 +36,14 @@ func NewServer(stop <-chan struct{}) *server {
3636 mux := http .NewServeMux ()
3737 srv := & server {
3838 Server : http.Server {
39- Addr : fmt .Sprintf (":%d" , tb .ServerPort ),
39+ Addr : fmt .Sprintf (":%d" , util .ServerPort ),
4040 Handler : mux ,
4141 },
4242 }
4343
4444 // Add handle functions
45- mux .HandleFunc (tb . ServerProbePath , srv .healthHandle )
46- mux .Handle (tb . ServerBackupPath , tb .MaxClients (http .HandlerFunc (srv .serveBackupHandle ), 1 ))
45+ mux .HandleFunc (util . ServerProbeEndpoint , srv .healthHandler )
46+ mux .Handle (util . ServerBackupEndpoint , util .MaxClients (http .HandlerFunc (srv .backupHandler ), 1 ))
4747
4848 // Shutdown gracefully the http server
4949 go func () {
@@ -56,12 +56,12 @@ func NewServer(stop <-chan struct{}) *server {
5656 return srv
5757}
5858
59- func (s * server ) healthHandle (w http.ResponseWriter , r * http.Request ) {
59+ func (s * server ) healthHandler (w http.ResponseWriter , r * http.Request ) {
6060 w .WriteHeader (http .StatusOK )
6161 w .Write ([]byte ("OK" ))
6262}
6363
64- func (s * server ) serveBackupHandle (w http.ResponseWriter , r * http.Request ) {
64+ func (s * server ) backupHandler (w http.ResponseWriter , r * http.Request ) {
6565
6666 if ! s .isAuthenticated (r ) {
6767 http .Error (w , "Not authenticated!" , http .StatusForbidden )
@@ -78,8 +78,8 @@ func (s *server) serveBackupHandle(w http.ResponseWriter, r *http.Request) {
7878 w .Header ().Set ("Connection" , "keep-alive" )
7979
8080 xtrabackup := exec .Command ("xtrabackup" , "--backup" , "--slave-info" , "--stream=xbstream" ,
81- "--host=127.0.0.1" , fmt .Sprintf ("--user=%s" , tb .GetReplUser ()),
82- fmt .Sprintf ("--password=%s" , tb .GetReplPass ()))
81+ "--host=127.0.0.1" , fmt .Sprintf ("--user=%s" , util .GetReplUser ()),
82+ fmt .Sprintf ("--password=%s" , util .GetReplPass ()))
8383
8484 xtrabackup .Stderr = os .Stderr
8585
@@ -115,5 +115,5 @@ func (s *server) serveBackupHandle(w http.ResponseWriter, r *http.Request) {
115115
116116func (s * server ) isAuthenticated (r * http.Request ) bool {
117117 user , pass , ok := r .BasicAuth ()
118- return ok && user == tb .GetBackupUser () && pass == tb .GetBackupPass ()
118+ return ok && user == util .GetBackupUser () && pass == util .GetBackupPass ()
119119}
0 commit comments