(path string, f http.Handler)
| 42 | } |
| 43 | |
| 44 | func (config *HTTP) Handle(path string, f http.Handler) { |
| 45 | if config.mux == nil { |
| 46 | config.mux = http.NewServeMux() |
| 47 | } |
| 48 | if config.CORS { |
| 49 | f = util.CORS(f) |
| 50 | } |
| 51 | if config.UserName != "" && config.Password != "" { |
| 52 | f = util.BasicAuth(config.UserName, config.Password, f) |
| 53 | } |
| 54 | for _, middleware := range config.middlewares { |
| 55 | f = middleware(path, f) |
| 56 | } |
| 57 | config.mux.Handle(path, f) |
| 58 | } |
| 59 | |
| 60 | func (config *HTTP) GetHTTPConfig() *HTTP { |
| 61 | return config |