Julian Brost avatar Julian Brost committed e1cea24

Weird closure stuff.

Comments (0)

Files changed (1)

 	// init views
 	app.ServeMux = http.NewServeMux()
 	for base, view := range appViews {
-		handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-			view(app, w, r)
-		})
-		app.ServeMux.Handle(base, handler)
+		app.ServeMux.Handle(base, app.makeHandler(view))
 	}
 
 	return app, nil
 }
 
+func (app *App) makeHandler(view View) http.Handler {
+	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+		view(app, w, r)
+	})
+}
+
 type View func(*App, http.ResponseWriter, *http.Request)
 
 func RegisterView(base string, view View) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.