apiroutecache

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: GPL-3.0 Imports: 8 Imported by: 1

README

apiroutecache

It is client side cache of routes registered with AuthServer for quick access and validation by specific API server.

AuthServer is private project, so it may not be usable without that.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouteInfo

func NewRouteInfo(scope, controller, endpoint, method string, precedence int) models.RouteInfo

NewRouteInfo create new RouteInfo struct

Types

type MongoConfig

type MongoConfig struct {
	Host        string
	Port        int
	DbName      string
	User        string
	Pwd         string
	ConnTimeout int // in seconds
}

MongoConfig is config for mongodb connection

type MongoSession

type MongoSession struct {
	*mgo.Session
	DBname string
}

MongoSession holds session for mongodb connection

func InitSession

func InitSession(config MongoConfig) *MongoSession

InitSession initialize mongodb session

func (*MongoSession) Cleanup

func (s *MongoSession) Cleanup()

Cleanup closes existing mongodb session

func (*MongoSession) DeleteRoutesByScope

func (m *MongoSession) DeleteRoutesByScope(scope string) error

DeleteRoutesByScope remove all routes defined in given scope

func (*MongoSession) FindRoutes

func (m *MongoSession) FindRoutes(controller, endpoint, method string) (*[]models.RouteInfo, error)

FindRoutes lookup for route for given controller/endpoint and method

func (*MongoSession) GetAllRoutes

func (m *MongoSession) GetAllRoutes() (*[]models.RouteInfo, error)

GetAllRoutes returns list of all routes

func (*MongoSession) GetScopesFromRoute

func (m *MongoSession) GetScopesFromRoute(controller, endpoint, method string) (*[]string, error)

GetScopesFromRoute query and return []string of scoped for given route

func (*MongoSession) InsertRoutes

func (m *MongoSession) InsertRoutes(routes *[]models.RouteInfo, setIDs bool) error

InsertRoutes only insert list of given routes to database

if route already exist, it will panic

func (*MongoSession) SaveRoutes

func (m *MongoSession) SaveRoutes(routes *[]models.RouteInfo) error

SaveRoutes insert or update one or more routes to database

func (*MongoSession) TruncateRoutes

func (m *MongoSession) TruncateRoutes() error

TruncateRoutes removes all routes from database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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