Skip to content

martini-contrib/accessflags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

accessflags wercker status

accessflags is a Martini handler to enable Access Control, such as role-based access control support, through an integer flag.

API Reference

Usage

package main

import (
	"github.com/martini-contrib/accessflags"
	"github.com/codegangsta/martini"
)

const (
	rolePassAll = 0
	roleRobot   = 1
	roleSignOn  = 2
	roleAdmin   = 4 | roleSignOn
)

func main() {
	m := martini.Classic()

	m.Use(judge) // first Map flag for role
	m.Get("/profile", accessflags.Forbidden(roleSignOn), profileHandler)
	m.Get("/admin", accessflags.Forbidden(roleAdmin), adminHandler)

	m.Run()
}

func judge(c martini.Context) martini.Handler{
	// something
	c.Map(roleRobot) // roleSignOn...
}

func adminHandler() string{
	// something
	return "hello"
}
func profileHandler() string{
	// something
	return "profile"
}

Authors

About

Martini handler to enable Access Control.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages