{"action":"created","comment":{"url":"https://api.github.com/repos/containous/traefik/pulls/comments/114087449","pull_request_review_id":35528384,"id":114087449,"diff_hunk":"@@ -175,31 +188,46 @@ func (server *Server) startHTTPServers() {\n \tserver.serverEntryPoints = server.buildEntryPoints(server.globalConfiguration)\n \n \tfor newServerEntryPointName, newServerEntryPoint := range server.serverEntryPoints {\n-\t\tserverMiddlewares := []negroni.Handler{server.accessLoggerMiddleware, server.loggerMiddleware, metrics}\n-\t\tif server.globalConfiguration.Web != nil && server.globalConfiguration.Web.Metrics != nil {\n-\t\t\tif server.globalConfiguration.Web.Metrics.Prometheus != nil {\n-\t\t\t\tmetricsMiddleware := middlewares.NewMetricsWrapper(middlewares.NewPrometheus(newServerEntryPointName, server.globalConfiguration.Web.Metrics.Prometheus))\n-\t\t\t\tserverMiddlewares = append(serverMiddlewares, metricsMiddleware)\n-\t\t\t}\n-\t\t}\n-\t\tif server.globalConfiguration.Web != nil && server.globalConfiguration.Web.Statistics != nil {\n-\t\t\tstatsRecorder = middlewares.NewStatsRecorder(server.globalConfiguration.Web.Statistics.RecentErrors)\n-\t\t\tserverMiddlewares = append(serverMiddlewares, statsRecorder)\n+\t\t// build a filter chain of: log, metrics (wrapping prometheus), stats, authenticator, compress, router\n+\t\t// (working right to left)\n+\n+\t\tvar chain http.Handler = newServerEntryPoint.httpRouter\n+\n+\t\tif server.globalConfiguration.EntryPoints[newServerEntryPointName].Compress {\n+\t\t\tchain = middlewares.NewCompress(chain)\n \t\t}\n+\n \t\tif server.globalConfiguration.EntryPoints[newServerEntryPointName].Auth != nil {\n-\t\t\tauthMiddleware, err := middlewares.NewAuthenticator(server.globalConfiguration.EntryPoints[newServerEntryPointName].Auth)\n+\t\t\tvar err error\n+\t\t\tauthConfig := server.globalConfiguration.EntryPoints[newServerEntryPointName].Auth\n+\t\t\tchain, err = middlewares.NewAuthenticator(authConfig, chain)\n \t\t\tif err != nil {\n \t\t\t\tlog.Fatal(\"Error starting server: \", err)\n \t\t\t}\n-\t\t\tserverMiddlewares = append(serverMiddlewares, authMiddleware)\n \t\t}\n-\t\tif server.globalConfiguration.EntryPoints[newServerEntryPointName].Compress {\n-\t\t\tserverMiddlewares = append(serverMiddlewares, &middlewares.Compress{})\n+\n+\t\tweb := server.globalConfiguration.Web\n+\t\tif web != nil && web.Statistics != nil {\n+\t\t\tchain = middlewares.NewStatsRecorder(web.Statistics.RecentErrors, chain)\n \t\t}\n-\t\tnewsrv, err := server.prepareServer(newServerEntryPointName, newServerEntryPoint.httpRouter, server.globalConfiguration.EntryPoints[newServerEntryPointName], serverMiddlewares...)\n+\n+\t\tif web != nil && web.Metrics != nil && web.Metrics.Prometheus != nil {\n+\t\t\tp := middlewares.NewPrometheus(newServerEntryPointName, web.Metrics.Prometheus)\n+\t\t\tchain = middlewares.NewMetricsWrapper(p, chain)\n+\t\t}\n+\n+\t\tchain = common.NewAdapter(metrics, chain)","path":"server/server.go","position":127,"original_position":127,"commit_id":"08eaf9d2978e9b23c84cd56b75580992ab02ab8a","original_commit_id":"08eaf9d2978e9b23c84cd56b75580992ab02ab8a","user":{"login":"timoreimann","id":694826,"avatar_url":"https://avatars2.githubusercontent.com/u/694826?v=3","gravatar_id":"","url":"https://api.github.com/users/timoreimann","html_url":"https://github.com/timoreimann","followers_url":"https://api.github.com/users/timoreimann/followers","following_url":"https://api.github.com/users/timoreimann/following{/other_user}","gists_url":"https://api.github.com/users/timoreimann/gists{/gist_id}","starred_url":"https://api.github.com/users/timoreimann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timoreimann/subscriptions","organizations_url":"https://api.github.com/users/timoreimann/orgs","repos_url":"https://api.github.com/users/timoreimann/repos","events_url":"https://api.github.com/users/timoreimann/events{/privacy}","received_events_url":"https://api.github.com/users/timoreimann/received_events","type":"User","site_admin":false},"body":"AFAICS, this is the only occurrence where we need the negroni adapter. Do you think there's a way to get rid of this last bit (and that we should try to)?","created_at":"2017-04-30T23:40:53Z","updated_at":"2017-04-30T23:51:23Z","html_url":"https://github.com/containous/traefik/pull/1391#discussion_r114087449","pull_request_url":"https://api.github.com/repos/containous/traefik/pulls/1391","_links":{"self":{"href":"https://api.github.com/repos/containous/traefik/pulls/comments/114087449"},"html":{"href":"https://github.com/containous/traefik/pull/1391#discussion_r114087449"},"pull_request":{"href":"https://api.github.com/repos/containous/traefik/pulls/1391"}}},"pull_request":{"url":"https://api.github.com/repos/containous/traefik/pulls/1391","id":114443574,"html_url":"https://github.com/containous/traefik/pull/1391","diff_url":"https://github.com/containous/traefik/pull/1391.diff","patch_url":"https://github.com/containous/traefik/pull/1391.patch","issue_url":"https://api.github.com/repos/containous/traefik/issues/1391","number":1391,"state":"open","locked":false,"title":"New middleware","user":{"login":"rickb777","id":1358735,"avatar_url":"https://avatars1.githubusercontent.com/u/1358735?v=3","gravatar_id":"","url":"https://api.github.com/users/rickb777","html_url":"https://github.com/rickb777","followers_url":"https://api.github.com/users/rickb777/followers","following_url":"https://api.github.com/users/rickb777/following{/other_user}","gists_url":"https://api.github.com/users/rickb777/gists{/gist_id}","starred_url":"https://api.github.com/users/rickb777/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickb777/subscriptions","organizations_url":"https://api.github.com/users/rickb777/orgs","repos_url":"https://api.github.com/users/rickb777/repos","events_url":"https://api.github.com/users/rickb777/events{/privacy}","received_events_url":"https://api.github.com/users/rickb777/received_events","type":"User","site_admin":false},"body":"This PR contains the rewrite of the server.go code that removes the dependency on Negroni. It's replaced by simple internal middleware chaining. This also adds the ability to invoke a Close() method on any middleware that needs it.","created_at":"2017-04-05T18:32:51Z","updated_at":"2017-04-30T23:51:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"50d72280c7349f515a7707cda8bdba19c9742d1b","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/containous/traefik/milestones/5","html_url":"https://github.com/containous/traefik/milestone/5","labels_url":"https://api.github.com/repos/containous/traefik/milestones/5/labels","id":2302121,"number":5,"title":"1.3","description":null,"creator":{"login":"emilevauge","id":6207234,"avatar_url":"https://avatars0.githubusercontent.com/u/6207234?v=3","gravatar_id":"","url":"https://api.github.com/users/emilevauge","html_url":"https://github.com/emilevauge","followers_url":"https://api.github.com/users/emilevauge/followers","following_url":"https://api.github.com/users/emilevauge/following{/other_user}","gists_url":"https://api.github.com/users/emilevauge/gists{/gist_id}","starred_url":"https://api.github.com/users/emilevauge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emilevauge/subscriptions","organizations_url":"https://api.github.com/users/emilevauge/orgs","repos_url":"https://api.github.com/users/emilevauge/repos","events_url":"https://api.github.com/users/emilevauge/events{/privacy}","received_events_url":"https://api.github.com/users/emilevauge/received_events","type":"User","site_admin":false},"open_issues":15,"closed_issues":62,"state":"open","created_at":"2017-02-06T10:07:23Z","updated_at":"2017-04-30T23:46:16Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/containous/traefik/pulls/1391/commits","review_comments_url":"https://api.github.com/repos/containous/traefik/pulls/1391/comments","review_comment_url":"https://api.github.com/repos/containous/traefik/pulls/comments{/number}","comments_url":"https://api.github.com/repos/containous/traefik/issues/1391/comments","statuses_url":"https://api.github.com/repos/containous/traefik/statuses/08eaf9d2978e9b23c84cd56b75580992ab02ab8a","head":{"label":"hmrc:new-middleware","ref":"new-middleware","sha":"08eaf9d2978e9b23c84cd56b75580992ab02ab8a","user":{"login":"hmrc","id":5755339,"avatar_url":"https://avatars2.githubusercontent.com/u/5755339?v=3","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"repo":{"id":82560298,"name":"traefik","full_name":"hmrc/traefik","owner":{"login":"hmrc","id":5755339,"avatar_url":"https://avatars2.githubusercontent.com/u/5755339?v=3","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmrc/traefik","description":"Træfɪk, a modern reverse proxy","fork":true,"url":"https://api.github.com/repos/hmrc/traefik","forks_url":"https://api.github.com/repos/hmrc/traefik/forks","keys_url":"https://api.github.com/repos/hmrc/traefik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmrc/traefik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmrc/traefik/teams","hooks_url":"https://api.github.com/repos/hmrc/traefik/hooks","issue_events_url":"https://api.github.com/repos/hmrc/traefik/issues/events{/number}","events_url":"https://api.github.com/repos/hmrc/traefik/events","assignees_url":"https://api.github.com/repos/hmrc/traefik/assignees{/user}","branches_url":"https://api.github.com/repos/hmrc/traefik/branches{/branch}","tags_url":"https://api.github.com/repos/hmrc/traefik/tags","blobs_url":"https://api.github.com/repos/hmrc/traefik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmrc/traefik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmrc/traefik/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmrc/traefik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmrc/traefik/statuses/{sha}","languages_url":"https://api.github.com/repos/hmrc/traefik/languages","stargazers_url":"https://api.github.com/repos/hmrc/traefik/stargazers","contributors_url":"https://api.github.com/repos/hmrc/traefik/contributors","subscribers_url":"https://api.github.com/repos/hmrc/traefik/subscribers","subscription_url":"https://api.github.com/repos/hmrc/traefik/subscription","commits_url":"https://api.github.com/repos/hmrc/traefik/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmrc/traefik/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmrc/traefik/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmrc/traefik/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmrc/traefik/contents/{+path}","compare_url":"https://api.github.com/repos/hmrc/traefik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmrc/traefik/merges","archive_url":"https://api.github.com/repos/hmrc/traefik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmrc/traefik/downloads","issues_url":"https://api.github.com/repos/hmrc/traefik/issues{/number}","pulls_url":"https://api.github.com/repos/hmrc/traefik/pulls{/number}","milestones_url":"https://api.github.com/repos/hmrc/traefik/milestones{/number}","notifications_url":"https://api.github.com/repos/hmrc/traefik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmrc/traefik/labels{/name}","releases_url":"https://api.github.com/repos/hmrc/traefik/releases{/id}","deployments_url":"https://api.github.com/repos/hmrc/traefik/deployments","created_at":"2017-02-20T13:22:14Z","updated_at":"2017-02-20T13:22:17Z","pushed_at":"2017-04-28T14:15:35Z","git_url":"git://github.com/hmrc/traefik.git","ssh_url":"git@github.com:hmrc/traefik.git","clone_url":"https://github.com/hmrc/traefik.git","svn_url":"https://github.com/hmrc/traefik","homepage":"https://traefik.io/","size":17007,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"containous:master","ref":"master","sha":"5a8215a1e46306b69aa20d775a27c274edc9a990","user":{"login":"containous","id":16349663,"avatar_url":"https://avatars0.githubusercontent.com/u/16349663?v=3","gravatar_id":"","url":"https://api.github.com/users/containous","html_url":"https://github.com/containous","followers_url":"https://api.github.com/users/containous/followers","following_url":"https://api.github.com/users/containous/following{/other_user}","gists_url":"https://api.github.com/users/containous/gists{/gist_id}","starred_url":"https://api.github.com/users/containous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/containous/subscriptions","organizations_url":"https://api.github.com/users/containous/orgs","repos_url":"https://api.github.com/users/containous/repos","events_url":"https://api.github.com/users/containous/events{/privacy}","received_events_url":"https://api.github.com/users/containous/received_events","type":"Organization","site_admin":false},"repo":{"id":42408804,"name":"traefik","full_name":"containous/traefik","owner":{"login":"containous","id":16349663,"avatar_url":"https://avatars0.githubusercontent.com/u/16349663?v=3","gravatar_id":"","url":"https://api.github.com/users/containous","html_url":"https://github.com/containous","followers_url":"https://api.github.com/users/containous/followers","following_url":"https://api.github.com/users/containous/following{/other_user}","gists_url":"https://api.github.com/users/containous/gists{/gist_id}","starred_url":"https://api.github.com/users/containous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/containous/subscriptions","organizations_url":"https://api.github.com/users/containous/orgs","repos_url":"https://api.github.com/users/containous/repos","events_url":"https://api.github.com/users/containous/events{/privacy}","received_events_url":"https://api.github.com/users/containous/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/containous/traefik","description":"Træfik, a modern reverse proxy","fork":false,"url":"https://api.github.com/repos/containous/traefik","forks_url":"https://api.github.com/repos/containous/traefik/forks","keys_url":"https://api.github.com/repos/containous/traefik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/containous/traefik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/containous/traefik/teams","hooks_url":"https://api.github.com/repos/containous/traefik/hooks","issue_events_url":"https://api.github.com/repos/containous/traefik/issues/events{/number}","events_url":"https://api.github.com/repos/containous/traefik/events","assignees_url":"https://api.github.com/repos/containous/traefik/assignees{/user}","branches_url":"https://api.github.com/repos/containous/traefik/branches{/branch}","tags_url":"https://api.github.com/repos/containous/traefik/tags","blobs_url":"https://api.github.com/repos/containous/traefik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/containous/traefik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/containous/traefik/git/refs{/sha}","trees_url":"https://api.github.com/repos/containous/traefik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/containous/traefik/statuses/{sha}","languages_url":"https://api.github.com/repos/containous/traefik/languages","stargazers_url":"https://api.github.com/repos/containous/traefik/stargazers","contributors_url":"https://api.github.com/repos/containous/traefik/contributors","subscribers_url":"https://api.github.com/repos/containous/traefik/subscribers","subscription_url":"https://api.github.com/repos/containous/traefik/subscription","commits_url":"https://api.github.com/repos/containous/traefik/commits{/sha}","git_commits_url":"https://api.github.com/repos/containous/traefik/git/commits{/sha}","comments_url":"https://api.github.com/repos/containous/traefik/comments{/number}","issue_comment_url":"https://api.github.com/repos/containous/traefik/issues/comments{/number}","contents_url":"https://api.github.com/repos/containous/traefik/contents/{+path}","compare_url":"https://api.github.com/repos/containous/traefik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/containous/traefik/merges","archive_url":"https://api.github.com/repos/containous/traefik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/containous/traefik/downloads","issues_url":"https://api.github.com/repos/containous/traefik/issues{/number}","pulls_url":"https://api.github.com/repos/containous/traefik/pulls{/number}","milestones_url":"https://api.github.com/repos/containous/traefik/milestones{/number}","notifications_url":"https://api.github.com/repos/containous/traefik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/containous/traefik/labels{/name}","releases_url":"https://api.github.com/repos/containous/traefik/releases{/id}","deployments_url":"https://api.github.com/repos/containous/traefik/deployments","created_at":"2015-09-13T19:04:02Z","updated_at":"2017-04-30T21:14:21Z","pushed_at":"2017-04-30T20:46:04Z","git_url":"git://github.com/containous/traefik.git","ssh_url":"git@github.com:containous/traefik.git","clone_url":"https://github.com/containous/traefik.git","svn_url":"https://github.com/containous/traefik","homepage":"https://traefik.io/","size":17326,"stargazers_count":7794,"watchers_count":7794,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":718,"mirror_url":null,"open_issues_count":386,"forks":718,"open_issues":386,"watchers":7794,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/containous/traefik/pulls/1391"},"html":{"href":"https://github.com/containous/traefik/pull/1391"},"issue":{"href":"https://api.github.com/repos/containous/traefik/issues/1391"},"comments":{"href":"https://api.github.com/repos/containous/traefik/issues/1391/comments"},"review_comments":{"href":"https://api.github.com/repos/containous/traefik/pulls/1391/comments"},"review_comment":{"href":"https://api.github.com/repos/containous/traefik/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/containous/traefik/pulls/1391/commits"},"statuses":{"href":"https://api.github.com/repos/containous/traefik/statuses/08eaf9d2978e9b23c84cd56b75580992ab02ab8a"}}}}
{"actor":{"display_login":"timoreimann"}}