server

package
v0.0.0-...-a85dc47 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BodyLimitBytes uint32 = 1048576 * 5

Request JSON body limit is set at 5MB (currently not enforced)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessController

type AccessController struct {
	ACLMap domain.ACLMap
	// contains filtered or unexported fields
}

implements IAccessController

func NewAccessController

func NewAccessController(ctx domain.IContext, renderer domain.IRenderer) *AccessController

TODO: Currently, AccessController only acts as a gateway for endpoints on router level. Build AC to handler other aspects of ACL

func (*AccessController) Add

func (ac *AccessController) Add(aclMap *domain.ACLMap)

func (*AccessController) AddHandler

func (ac *AccessController) AddHandler(action string, handler domain.ACLHandlerFunc)

func (*AccessController) HasAction

func (ac *AccessController) HasAction(action string) bool

func (*AccessController) IsHTTPRequestAuthorized

func (ac *AccessController) IsHTTPRequestAuthorized(req *http.Request, ctx domain.IContext, action string, user domain.IUser) (bool, string)

func (*AccessController) NewContextHandler

func (ac *AccessController) NewContextHandler(action string, next http.HandlerFunc) http.HandlerFunc

type Config

type Config struct {
	Context domain.IContext
}

Config type

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message,omitempty"`
	Success bool   `json:"success"`
}

type Options

type Options struct {
	Timeout         time.Duration
	ShutdownHandler func()
}

Options for running the server

type Router

type Router struct {
	*mux.Router
	// contains filtered or unexported fields
}

Router type

func NewRouter

func NewRouter(ctx domain.IContext, ac domain.IAccessController) *Router

NewRouter Returns a new Router object

func (*Router) AddResources

func (router *Router) AddResources(resources ...domain.IResource) *Router

func (*Router) AddRoutes

func (router *Router) AddRoutes(routes *domain.Routes) *Router

type Server

type Server struct {
	Context domain.IContext
	// contains filtered or unexported fields
}

Server type

func NewServer

func NewServer(options *Config) *Server

NewServer Returns a new Server object

func (*Server) Run

func (s *Server) Run(address string, options Options) *Server

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) *Server

func (*Server) Stop

func (s *Server) Stop()

func (*Server) UseContextMiddleware

func (s *Server) UseContextMiddleware(middleware domain.IContextMiddleware) *Server

func (*Server) UseMiddleware

func (s *Server) UseMiddleware(middleware domain.IMiddleware) *Server

func (*Server) UseRouter

func (s *Server) UseRouter(router *Router) *Server

Jump to

Keyboard shortcuts

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