| 954 | } |
| 955 | |
| 956 | func bigMux() Router { |
| 957 | var r *Mux |
| 958 | var sr3 *Mux |
| 959 | // var sr1, sr2, sr3, sr4, sr5, sr6 *Mux |
| 960 | r = NewRouter() |
| 961 | r.Use(func(next http.Handler) http.Handler { |
| 962 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 963 | ctx := context.WithValue(r.Context(), ctxKey{"requestID"}, "1") |
| 964 | next.ServeHTTP(w, r.WithContext(ctx)) |
| 965 | }) |
| 966 | }) |
| 967 | r.Use(func(next http.Handler) http.Handler { |
| 968 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 969 | next.ServeHTTP(w, r) |
| 970 | }) |
| 971 | }) |
| 972 | r.Group(func(r Router) { |
| 973 | r.Use(func(next http.Handler) http.Handler { |
| 974 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 975 | ctx := context.WithValue(r.Context(), ctxKey{"session.user"}, "anonymous") |
| 976 | next.ServeHTTP(w, r.WithContext(ctx)) |
| 977 | }) |
| 978 | }) |
| 979 | r.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { |
| 980 | w.Write([]byte("fav")) |
| 981 | }) |
| 982 | r.Get("/hubs/{hubID}/view", func(w http.ResponseWriter, r *http.Request) { |
| 983 | ctx := r.Context() |
| 984 | s := fmt.Sprintf("/hubs/%s/view reqid:%s session:%s", URLParam(r, "hubID"), |
| 985 | ctx.Value(ctxKey{"requestID"}), ctx.Value(ctxKey{"session.user"})) |
| 986 | w.Write([]byte(s)) |
| 987 | }) |
| 988 | r.Get("/hubs/{hubID}/view/*", func(w http.ResponseWriter, r *http.Request) { |
| 989 | ctx := r.Context() |
| 990 | s := fmt.Sprintf("/hubs/%s/view/%s reqid:%s session:%s", URLParamFromCtx(ctx, "hubID"), |
| 991 | URLParam(r, "*"), ctx.Value(ctxKey{"requestID"}), ctx.Value(ctxKey{"session.user"})) |
| 992 | w.Write([]byte(s)) |
| 993 | }) |
| 994 | r.Post("/hubs/{hubSlug}/view/*", func(w http.ResponseWriter, r *http.Request) { |
| 995 | ctx := r.Context() |
| 996 | s := fmt.Sprintf("/hubs/%s/view/%s reqid:%s session:%s", URLParamFromCtx(ctx, "hubSlug"), |
| 997 | URLParam(r, "*"), ctx.Value(ctxKey{"requestID"}), ctx.Value(ctxKey{"session.user"})) |
| 998 | w.Write([]byte(s)) |
| 999 | }) |
| 1000 | }) |
| 1001 | r.Group(func(r Router) { |
| 1002 | r.Use(func(next http.Handler) http.Handler { |
| 1003 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 1004 | ctx := context.WithValue(r.Context(), ctxKey{"session.user"}, "elvis") |
| 1005 | next.ServeHTTP(w, r.WithContext(ctx)) |
| 1006 | }) |
| 1007 | }) |
| 1008 | r.Get("/", func(w http.ResponseWriter, r *http.Request) { |
| 1009 | ctx := r.Context() |
| 1010 | s := fmt.Sprintf("/ reqid:%s session:%s", ctx.Value(ctxKey{"requestID"}), ctx.Value(ctxKey{"session.user"})) |
| 1011 | w.Write([]byte(s)) |
| 1012 | }) |
| 1013 | r.Get("/suggestions", func(w http.ResponseWriter, r *http.Request) { |