server

package
v0.0.0-...-ef78331 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthLogin

func AuthLogin(w http.ResponseWriter, username, password string, sessions auth.SessionManager, users auth.UserManager, hasher auth.Hasher, c config.CookieConfig) bool

TODO Move to actual auth package

Types

type AnonUser

type AnonUser struct{}

AnonUser is a anonymous user that can never be considered authenticated

func (*AnonUser) IsAuthenticated

func (u *AnonUser) IsAuthenticated() bool

IsAuthenticated will always return false for AnonUser instances

func (*AnonUser) Name

func (u *AnonUser) Name() string

type Attrs

type Attrs map[string]interface{}

func (Attrs) Merge

func (a Attrs) Merge(b map[string]interface{})

type AuthUser

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

func (*AuthUser) IsAuthenticated

func (u *AuthUser) IsAuthenticated() bool

IsAuthenticated will always return false for AnonUser instances

func (*AuthUser) Name

func (u *AuthUser) Name() string

type ErrorHTTP

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

func (ErrorHTTP) Code

func (e ErrorHTTP) Code() int

func (ErrorHTTP) Error

func (e ErrorHTTP) Error() string

func (ErrorHTTP) Message

func (e ErrorHTTP) Message() string

type Handle

type Handler

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

TODO Ugly, but we want templates and configuration

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PublicHandle

type PublicHandle func(http.ResponseWriter, *http.Request) ServerError

func (PublicHandle) ServeHTTP

func (f PublicHandle) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Server

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

func New

func New(c config.Config) (srv *Server)

func (*Server) AddPublicRoute

func (srv *Server) AddPublicRoute(route string, h PublicHandle)

func (*Server) AddUserRoute

func (srv *Server) AddUserRoute(route string, h Handle)

func (*Server) Attrs

func (srv *Server) Attrs(b map[string]interface{}) map[string]interface{}

func (*Server) Execute

func (srv *Server) Execute(w http.ResponseWriter, name string, data Attrs)

func (*Server) ExecuteLayout

func (srv *Server) ExecuteLayout(w http.ResponseWriter, name string, d Attrs)

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

func (*Server) Login

func (srv *Server) Login(w http.ResponseWriter, r *http.Request) ServerError

func (*Server) Logout

func (srv *Server) Logout(w http.ResponseWriter, r *http.Request) ServerError

func (*Server) Root

func (srv *Server) Root(w http.ResponseWriter, r *http.Request, user User) ServerError

type ServerError

type ServerError interface {
	error
	Code() int
	Message() string
}

type User

type User interface {
	Name() string
	IsAuthenticated() bool
}

Jump to

Keyboard shortcuts

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