* fix: ssbc urls Closes https://github.com/ssbc/go-ssb-room/issues/332 * fix: go-ssb-refs API changes * test: go-ssb-refs API changes Co-authored-by: decentral1se <cellarspoon@riseup.net> Co-authored-by: André Staltz <andre@staltz.com>
26 lines
879 B
Go
26 lines
879 B
Go
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package members
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
|
)
|
|
|
|
// MiddlewareForTests gives us a way to inject _test members_. It should not be used in production.
|
|
// This is part of testing.go because we need to use roomMemberContextKey, which shouldn't be exported either.
|
|
// TODO: could be protected with an extra build tag.
|
|
// (Sadly +build test does not exist https://github.com/golang/go/issues/21360 )
|
|
func MiddlewareForTests(m *roomdb.Member) func(http.Handler) http.Handler {
|
|
return func(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
ctx := context.WithValue(req.Context(), roomMemberContextKey, m)
|
|
next.ServeHTTP(w, req.WithContext(ctx))
|
|
})
|
|
}
|
|
}
|