service

package
v0.0.0-...-e107a19 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ReqBodyLimit int64 = 1048576 //1024*1024

ReqBodyLimit - Req Body Size limit in bytes

View Source
const RestAPIBasePath = "/flixcultapi"

RestAPIBasePath - ..

Variables

DefaultMWFuncs - Commonly used middlewarefunc

View Source
var Routes = []Route{
	Route{
		Methods:         []string{"POST"},
		Path:            "/login",
		HandlerFunc:     LoginREST,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"GET"},
		Path:            "/users",
		HandlerFunc:     GetAllUsers,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"GET"},
		Path:            "/users/:name",
		HandlerFunc:     GetUser,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"GET"},
		Path:            "/users/filtersearch",
		HandlerFunc:     GetUserByFilter,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"POST"},
		Path:            "/users/:name",
		HandlerFunc:     CreateUser,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"PUT"},
		Path:            "/users/:name",
		HandlerFunc:     UpdateUser,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"DELETE"},
		Path:            "/users/:name",
		HandlerFunc:     DeleteUser,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"GET"},
		Path:            "/groups",
		HandlerFunc:     GetAllGroups,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"GET"},
		Path:            "/groups/:groupID",
		HandlerFunc:     GetGroup,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"POST"},
		Path:            "/groups/:groupID",
		HandlerFunc:     CreateGroup,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"PUT"},
		Path:            "/groups/:groupID",
		HandlerFunc:     UpdateGroup,
		MiddlewareFuncs: DefaultMWFuncs,
	},

	Route{
		Methods:         []string{"DELETE"},
		Path:            "/groups/:groupID",
		HandlerFunc:     DeleteGroup,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"PUT"},
		Path:            "/groups/:groupID/users/add",
		HandlerFunc:     AddUserToGroup,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"PUT"},
		Path:            "/groups/:groupID/users/remove",
		HandlerFunc:     RemoveUserFromGroup,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"GET"},
		Path:            "groups/:groupID/users",
		HandlerFunc:     GetUsersInGroup,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"GET"},
		Path:            "groups/:groupID/users/filtersearch",
		HandlerFunc:     GroupHasUser,
		MiddlewareFuncs: DefaultMWFuncs,
	},
	Route{
		Methods:         []string{"GET"},
		Path:            "users/:name/groups",
		HandlerFunc:     GetGroupsForUser,
		MiddlewareFuncs: DefaultMWFuncs,
	},
}

Routes - Stores all routes(each of type Route)

Functions

func AddUserToGroup

func AddUserToGroup(c echo.Context) error

AddUserToGroup - Add a user to group

func CreateGroup

func CreateGroup(c echo.Context) error

CreateGroup - Create Group

func CreateUser

func CreateUser(c echo.Context) error

CreateUser - Create User

func DeleteGroup

func DeleteGroup(c echo.Context) error

DeleteGroup - Delete Group based on groupID

func DeleteUser

func DeleteUser(c echo.Context) error

DeleteUser - Delete user based on username

func GetAllGroups

func GetAllGroups(c echo.Context) error

GetAllGroups - Get all groups

func GetAllUsers

func GetAllUsers(c echo.Context) error

GetAllUsers - Get list of users- Implemented with Echo JSON Streaming to support large JSON objects

func GetGroup

func GetGroup(c echo.Context) error

GetGroup - Get group based on groupID

func GetGroupsForUser

func GetGroupsForUser(c echo.Context) error

GetGroupsForUser - Get list of groups that a user is a part of

func GetUser

func GetUser(c echo.Context) error

GetUser - Get user based on username

func GetUserByFilter

func GetUserByFilter(c echo.Context) error

GetUserByFilter - Get user based on attributes apart from name Valid inputs - email

func GetUsersInGroup

func GetUsersInGroup(c echo.Context) error

GetUsersInGroup - Get list of users in a group

func GroupHasUser

func GroupHasUser(c echo.Context) error

GroupHasUser - Check if user exists in a group. User can be searched by name or email

func LoginREST

func LoginREST(c echo.Context) error

LoginREST - function to login. Expects POST request and returns JWT token

func RemoveUserFromGroup

func RemoveUserFromGroup(c echo.Context) error

RemoveUserFromGroup - Delete User from Group based on username, groupID

func SetupRestRoutes

func SetupRestRoutes(e *echo.Echo)

SetupRestRoutes - Set up all the routes based on Routes var

func StartRESTService

func StartRESTService(e *echo.Echo, hostname string, port string)

StartRESTService - Starts up a new REST API service

func UpdateGroup

func UpdateGroup(c echo.Context) error

UpdateGroup - Update Group

func UpdateUser

func UpdateUser(c echo.Context) error

UpdateUser - Update User

Types

type GroupUser

type GroupUser struct {
	Name    string `json:"name"`
	GroupID string `json:"groupID"`
}

GroupUser - groupID user name map

type Route

type Route struct {
	Methods         []string
	Path            string
	HandlerFunc     echo.HandlerFunc
	MiddlewareFuncs []echo.MiddlewareFunc
}

TODO : Versioning Route - Attributes of a route to be registered with router

Jump to

Keyboard shortcuts

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