Example #1
0
// Routes provides route for tenant service.
func (tsvc *TenantSvc) Routes() common.Routes {
	routes := common.Routes{
		common.Route{
			Method:      "POST",
			Pattern:     tenantsPath,
			Handler:     tsvc.addTenant,
			MakeMessage: func() interface{} { return &Tenant{} },
		},
		common.Route{
			Method:  "GET",
			Pattern: tenantsPath + "/{tenantId}",
			Handler: tsvc.getTenant,
		},
		common.Route{
			Method:  "GET",
			Pattern: tenantsPath,
			Handler: tsvc.listTenants,
		},
		common.Route{
			Method:      "POST",
			Pattern:     tenantsPath + "/{tenantId}" + segmentsPath,
			Handler:     tsvc.addSegment,
			MakeMessage: func() interface{} { return &Segment{} },
		},
		common.Route{
			Method:          "GET",
			Pattern:         tenantsPath + "/{tenantId}" + segmentsPath + "/{segmentId}",
			Handler:         tsvc.getSegment,
			MakeMessage:     nil,
			UseRequestToken: false,
		},
		common.Route{
			Method:          "GET",
			Pattern:         tenantsPath + "/{tenantId}" + segmentsPath,
			Handler:         tsvc.listSegments,
			MakeMessage:     nil,
			UseRequestToken: false,
		},
	}
	var t = []Tenant{}
	routes = append(routes, common.CreateFindRoutes(&t, &tsvc.store.DbStore)...)
	var s = []Segment{}
	routes = append(routes, common.CreateFindRoutes(&s, &tsvc.store.DbStore)...)
	return routes
}
Example #2
0
// Routes returns various routes used in the service.
func (topology *TopologySvc) Routes() common.Routes {
	infoRouteIndex := common.Route{
		Method:          "GET",
		Pattern:         "/",
		Handler:         topology.handleIndex,
		MakeMessage:     nil,
		UseRequestToken: false,
	}
	routes := common.Routes{
		infoRouteIndex,
		common.Route{
			Method:          "GET",
			Pattern:         hostListPath,
			Handler:         topology.handleHostListGet,
			MakeMessage:     nil,
			UseRequestToken: false,
		},
		common.Route{
			Method:          "POST",
			Pattern:         hostListPath,
			Handler:         topology.handleHostListPost,
			MakeMessage:     func() interface{} { return &common.Host{} },
			UseRequestToken: false,
		},
		common.Route{
			Method:          "GET",
			Pattern:         hostListPath + "/{hostId}",
			Handler:         topology.handleGetHost,
			MakeMessage:     nil,
			UseRequestToken: false,
		},
		common.Route{
			Method:          "GET",
			Pattern:         dcPath,
			Handler:         topology.handleDc,
			MakeMessage:     nil,
			UseRequestToken: false,
		},
	}
	var h = []common.Host{}
	routes = append(routes, common.CreateFindRoutes(&h, &topology.store.DbStore)...)
	return routes
}