web

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2014 License: Apache-2.0 Imports: 19 Imported by: 1

README

Go Incremental - Web

General purpose web interface library for use by goincremental projects, loosely wrapping best in class go web libraries

Documentation

Overview

Package oauth2 contains Negroni middleware to provide user login via an OAuth 2.0 backend.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Path to handle OAuth 2.0 logins.
	PathLogin = "/login"
	// Path to handle OAuth 2.0 logouts.
	PathLogout = "/logout"
	// Path to handle callback from OAuth 2.0 backend
	// to exchange credentials.
	PathCallback = "/oauth2callback"
	// Path to handle error cases.
	PathError = "/oauth2error"
)
View Source
var (
	ErrInvalidId       = errors.New("session: invalid session id")
	ErrInvalidModified = errors.New("mongostore: invalid modified value")
)

Functions

func Facebook added in v0.2.0

func Facebook(opts *oauth2.Options) http.Handler

func GetDb added in v0.2.0

func GetDb(r *http.Request) dal.Database

func Github added in v0.2.0

func Github(opts *oauth2.Options) http.Handler

Returns a new Github OAuth 2.0 backend endpoint.

func Google added in v0.2.0

func Google(opts *oauth2.Options) http.Handler

Returns a new Google OAuth 2.0 backend endpoint.

func LinkedIn added in v0.2.0

func LinkedIn(opts *oauth2.Options) http.Handler

func LoadEnv

func LoadEnv()

func NewOAuth2Provider added in v0.2.0

func NewOAuth2Provider(opts *oauth2.Options, authUrl, tokenUrl string) http.HandlerFunc

Returns a generic OAuth 2.0 backend endpoint.

func Params

func Params(req *http.Request) map[string]string

func SetDb added in v0.2.0

func SetDb(r *http.Request, val dal.Database)

func SetRenderer added in v0.2.0

func SetRenderer(r *http.Request, val Renderer)

func SetSession added in v0.2.0

func SetSession(r *http.Request, val *Session)

func SetSessionStore added in v0.2.0

func SetSessionStore(r *http.Request, val SessionStore)

Types

type Environment

type Environment interface {
	Load(filenames ...string) error
}

type Middleware

type Middleware interface {
	ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
}

func LoginRequired added in v0.2.0

func LoginRequired() Middleware

Handler that redirects user to the login page if user is not logged in.

type MiddlewareFunc added in v0.2.0

type MiddlewareFunc func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func (MiddlewareFunc) ServeHTTP added in v0.2.0

func (h MiddlewareFunc) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Options added in v0.2.0

type Options struct {
	Path   string
	Domain string
	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'.
	// MaxAge>0 means Max-Age attribute present and given in seconds.
	MaxAge   int
	Secure   bool
	HttpOnly bool
}

type Renderer

type Renderer interface {
	XML(w http.ResponseWriter, status int, v interface{})
	HTML(w http.ResponseWriter, status int, name string, binding interface{})
}

func GetRenderer added in v0.2.0

func GetRenderer(r *http.Request) Renderer

func NewRenderer

func NewRenderer() Renderer

type Route

type Route interface {
	Methods(s ...string) Route
}

type Router

type Router interface {
	http.Handler
	HandleFunc(s string, f func(http.ResponseWriter, *http.Request)) Route
	Handle(path string, handler http.Handler) Route
}

func NewRouter

func NewRouter() Router

type Server

type Server interface {
	Run(port string)
	Use(handler Middleware)
	UseHandler(http.Handler)
	ServeHTTP(rw http.ResponseWriter, r *http.Request)
}

func NewServer

func NewServer() Server

type Session added in v0.2.0

type Session struct {
	ID      string
	Values  map[interface{}]interface{}
	Options *Options
	IsNew   bool
	// contains filtered or unexported fields
}

func GetSession added in v0.2.0

func GetSession(r *http.Request) *Session

func (*Session) Delete added in v0.2.0

func (s *Session) Delete(key interface{})

func (*Session) Get added in v0.2.0

func (s *Session) Get(key interface{}) interface{}

func (*Session) Set added in v0.2.0

func (s *Session) Set(key interface{}, val interface{})

type SessionStore added in v0.2.0

type SessionStore interface {
	GetSession(r *http.Request, name string) (s *Session, err error)
	SaveSession(r *http.Request, w http.ResponseWriter, session *Session) error
}

func GetSessionStore added in v0.2.0

func GetSessionStore(r *http.Request) SessionStore

func NewSessionStore added in v0.2.0

func NewSessionStore(c dal.Collection, maxAge int, ensureTTL bool, keyPairs ...[]byte) SessionStore

NewSessionStore returns a new SessionStore (currently uses default dal implementation) Set ensureTTL to true let the database auto-remove expired object by maxAge.

type Tokens added in v0.2.0

type Tokens interface {
	Access() string
	Refresh() string
	IsExpired() bool
	ExpiryTime() time.Time
	ExtraData() map[string]string
}

Represents a container that contains user's OAuth 2.0 access and refresh tokens.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/codegangsta/negroni
Package negroni is an idiomatic approach to web middleware in Go.
Package negroni is an idiomatic approach to web middleware in Go.
_workspace/src/github.com/golang/oauth2
Package oauth2 provides support for making OAuth2 authorized and authenticated HTTP requests.
Package oauth2 provides support for making OAuth2 authorized and authenticated HTTP requests.
_workspace/src/github.com/golang/oauth2/google
Package google provides support for making OAuth2 authorized and authenticated HTTP requests to Google APIs.
Package google provides support for making OAuth2 authorized and authenticated HTTP requests to Google APIs.
_workspace/src/github.com/golang/oauth2/jws
Package jws provides encoding and decoding utilities for signed JWS messages.
Package jws provides encoding and decoding utilities for signed JWS messages.
_workspace/src/github.com/gorilla/context
Package context stores values shared during a request lifetime.
Package context stores values shared during a request lifetime.
_workspace/src/github.com/gorilla/mux
Package gorilla/mux implements a request router and dispatcher.
Package gorilla/mux implements a request router and dispatcher.
_workspace/src/github.com/gorilla/securecookie
Package gorilla/securecookie encodes and decodes authenticated and optionally encrypted cookie values.
Package gorilla/securecookie encodes and decodes authenticated and optionally encrypted cookie values.
_workspace/src/github.com/gorilla/sessions
Package gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends.
Package gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends.
_workspace/src/github.com/joho/godotenv
A go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) Examples/readme can be found on the github page at https://github.com/joho/godotenv The TL;DR is that you make a .env file that looks something like SOME_ENV_VAR=somevalue and then in your go code you can call godotenv.Load() and all the env vars declared in .env will be avaiable through os.Getenv("SOME_ENV_VAR")
A go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) Examples/readme can be found on the github page at https://github.com/joho/godotenv The TL;DR is that you make a .env file that looks something like SOME_ENV_VAR=somevalue and then in your go code you can call godotenv.Load() and all the env vars declared in .env will be avaiable through os.Getenv("SOME_ENV_VAR")
_workspace/src/labix.org/v2/mgo
Package mgo offers a rich MongoDB driver for Go.
Package mgo offers a rich MongoDB driver for Go.
_workspace/src/labix.org/v2/mgo/bson
Package bson is an implementation of the BSON specification for Go: http://bsonspec.org It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver.
Package bson is an implementation of the BSON specification for Go: http://bsonspec.org It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver.
_workspace/src/labix.org/v2/mgo/sasl
Package sasl is an implementation detail of the mgo package.
Package sasl is an implementation detail of the mgo package.
_workspace/src/labix.org/v2/mgo/txn
The txn package implements support for multi-document transactions.
The txn package implements support for multi-document transactions.

Jump to

Keyboard shortcuts

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