@@ -51,12 +51,13 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
5151}
5252
5353type API struct {
54- cfg Config
55- authMiddleware middleware.Interface
56- server * server.Server
57- logger log.Logger
58- sourceIPs * middleware.SourceIPExtractor
59- indexPage * IndexPageContent
54+ AuthMiddleware middleware.Interface
55+
56+ cfg Config
57+ server * server.Server
58+ logger log.Logger
59+ sourceIPs * middleware.SourceIPExtractor
60+ indexPage * IndexPageContent
6061}
6162
6263func New (cfg Config , serverCfg server.Config , s * server.Server , logger log.Logger ) (* API , error ) {
@@ -75,7 +76,7 @@ func New(cfg Config, serverCfg server.Config, s *server.Server, logger log.Logge
7576
7677 api := & API {
7778 cfg : cfg ,
78- authMiddleware : cfg .HTTPAuthMiddleware ,
79+ AuthMiddleware : cfg .HTTPAuthMiddleware ,
7980 server : s ,
8081 logger : logger ,
8182 sourceIPs : sourceIPs ,
@@ -84,7 +85,7 @@ func New(cfg Config, serverCfg server.Config, s *server.Server, logger log.Logge
8485
8586 // If no authentication middleware is present in the config, use the default authentication middleware.
8687 if cfg .HTTPAuthMiddleware == nil {
87- api .authMiddleware = middleware .AuthenticateUser
88+ api .AuthMiddleware = middleware .AuthenticateUser
8889 }
8990
9091 return api , nil
@@ -97,7 +98,7 @@ func (a *API) RegisterRoute(path string, handler http.Handler, auth bool, method
9798
9899 level .Debug (a .logger ).Log ("msg" , "api: registering route" , "methods" , strings .Join (methods , "," ), "path" , path , "auth" , auth )
99100 if auth {
100- handler = a .authMiddleware .Wrap (handler )
101+ handler = a .AuthMiddleware .Wrap (handler )
101102 }
102103 if len (methods ) == 0 {
103104 a .server .HTTP .Path (path ).Handler (handler )
@@ -109,7 +110,7 @@ func (a *API) RegisterRoute(path string, handler http.Handler, auth bool, method
109110func (a * API ) RegisterRoutesWithPrefix (prefix string , handler http.Handler , auth bool , methods ... string ) {
110111 level .Debug (a .logger ).Log ("msg" , "api: registering route" , "methods" , strings .Join (methods , "," ), "prefix" , prefix , "auth" , auth )
111112 if auth {
112- handler = a .authMiddleware .Wrap (handler )
113+ handler = a .AuthMiddleware .Wrap (handler )
113114 }
114115 if len (methods ) == 0 {
115116 a .server .HTTP .PathPrefix (prefix ).Handler (handler )
0 commit comments