auth

package
v0.0.0-...-c724f24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package auth provides filtering support for a martian.Proxy based on ctx.Auth.ID.

Index

Constants

This section is empty.

Variables

View Source
var ErrIDRequired = errors.New("ID required")

ErrIDRequired indicates that the filter must have an ID.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter filters RequestModifiers and ResponseModifiers by ctx.Auth.ID.

func NewFilter

func NewFilter() *Filter

NewFilter returns a new auth.Filter.

func (*Filter) ModifyRequest

func (f *Filter) ModifyRequest(ctx *martian.Context, req *http.Request) error

ModifyRequest runs the RequestModifier for the associated ctx.Auth.ID. If no modifier is found for ctx.Auth.ID then ctx.Auth.Error is set.

func (*Filter) ModifyResponse

func (f *Filter) ModifyResponse(ctx *martian.Context, res *http.Response) error

ModifyResponse runs the ResponseModifier for the associated ctx.Auth.ID. If no modifier is found for ctx.Auth.ID then ctx.Auth.Error is set.

func (*Filter) RequestModifier

func (f *Filter) RequestModifier(id string) martian.RequestModifier

RequestModifier retrieves the RequestModifier for the given ID. Returns nil if no modifier exists for the given ID.

func (*Filter) ResponseModifier

func (f *Filter) ResponseModifier(id string) martian.ResponseModifier

ResponseModifier retrieves the ResponseModifier for the given ID. Returns nil if no modifier exists for the given ID.

func (*Filter) SetAuthRequired

func (f *Filter) SetAuthRequired(required bool)

SetAuthRequired determines whether the ctx.Auth.ID must have an associated RequestModifier or ResponseModifier. If true, it will set ctx.Auth.Error.

func (*Filter) SetRequestModifier

func (f *Filter) SetRequestModifier(id string, reqmod martian.RequestModifier) error

SetRequestModifier sets the RequestModifier for the given ID. It will overwrite any existing modifier with the same ID. Returns ErrIDRequired if id is empty.

func (*Filter) SetResponseModifier

func (f *Filter) SetResponseModifier(id string, resmod martian.ResponseModifier) error

SetResponseModifier sets the ResponseModifier for the given ID. It will overwrite any existing modifier with the same ID. Returns ErrIDRequired if id is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL