// limitations under the License. // Package martianhttp provides HTTP handlers for managing the state of a martian.Proxy. package martianhttp import ( "io/ioutil" "net/http" "sync" "github.com/google/martian" "github.com/google/martian/parse" "github.com/google/martian/verify" ) var noop = martian.Noop("martianhttp.Modifier") // Modifier is a locking modifier that is configured via http.Handler. type Modifier struct { mu sync.RWMutex reqmod martian.RequestModifier resmod martian.ResponseModifier } // NewModifier returns a new martianhttp.Modifier. func NewModifier() *Modifier { return &Modifier{ reqmod: noop, resmod: noop, } }
// See the License for the specific language governing permissions and // limitations under the License. package martianurl import ( "encoding/json" "net/http" "net/url" "github.com/google/martian" "github.com/google/martian/parse" "github.com/google/martian/verify" ) var noop = martian.Noop("url.Filter") func init() { parse.Register("url.Filter", filterFromJSON) } // Filter runs modifiers iff the request URL matches all of the segments in url. type Filter struct { reqmod martian.RequestModifier resmod martian.ResponseModifier url *url.URL } type filterJSON struct { Scheme string `json:"scheme"` Host string `json:"host"`
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package querystring import ( "encoding/json" "net/http" "github.com/google/martian" "github.com/google/martian/parse" "github.com/google/martian/verify" ) var noop = martian.Noop("querystring.Filter") func init() { parse.Register("querystring.Filter", filterFromJSON) } // Filter runs modifiers iff the request query parameter for name matches value. type Filter struct { name string value string reqmod martian.RequestModifier resmod martian.ResponseModifier } type filterJSON struct { Name string `json:"name"`
// limitations under the License. // Package proxyauth provides authentication support via the // Proxy-Authorization header. package proxyauth import ( "encoding/base64" "net/http" "strings" "github.com/google/martian" "github.com/google/martian/auth" ) var noop = martian.Noop("proxyauth.Modifier") // Modifier is the proxy authentication modifier. type Modifier struct { reqmod martian.RequestModifier resmod martian.ResponseModifier } // NewModifier returns a new proxy authentication modifier. func NewModifier() *Modifier { return &Modifier{ reqmod: noop, resmod: noop, } }
// See the License for the specific language governing permissions and // limitations under the License. package header import ( "encoding/json" "net/http" "github.com/google/martian" "github.com/google/martian/parse" "github.com/google/martian/proxyutil" "github.com/google/martian/verify" ) var noop = martian.Noop("header.Filter") // Filter filters requests and responses based on header name and value. type Filter struct { name, value string reqmod martian.RequestModifier resmod martian.ResponseModifier } type filterJSON struct { Name string `json:"name"` Value string `json:"value"` Modifier json.RawMessage `json:"modifier"` Scope []parse.ModifierType `json:"scope"` }
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package ipauth provides a martian.Modifier that sets auth based on IP. package ipauth import ( "net" "net/http" "github.com/google/martian" "github.com/google/martian/auth" ) var noop = martian.Noop("ipauth.Modifier") // Modifier is the IP authentication modifier. type Modifier struct { reqmod martian.RequestModifier resmod martian.ResponseModifier } // NewModifier returns a new IP authentication modifier. func NewModifier() *Modifier { return &Modifier{ reqmod: noop, resmod: noop, } }