Move swappableMux and its methods to its own module

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-10-08 09:01:40 +02:00
parent 0cab49f082
commit 22f03eb67f
4 changed files with 146 additions and 141 deletions
-21
View File
@@ -2,29 +2,8 @@ package user
import (
"net/http"
"sync"
"github.com/gorilla/mux"
)
type swappableMux struct {
m sync.RWMutex
root mux.Router
}
func (sm *swappableMux) get() mux.Router {
sm.m.RLock()
defer sm.m.RUnlock()
return sm.root
}
func (sm *swappableMux) set(mux mux.Router) {
sm.m.Lock()
sm.root = mux
sm.m.Unlock()
}
var Server http.Server
func Run() {