Skip to content

Commit

Permalink
fix(lint): make controllers private for now
Browse files Browse the repository at this point in the history
  • Loading branch information
h2non committed Jun 4, 2016
1 parent 8d8e78c commit 85de7b8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
10 changes: 5 additions & 5 deletions manager/api.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package manager

// Initialize HTTP controllers
var index IndexController
var rules ScopesController
var scopes ScopesController
var plugins PluginsController
var instances InstancesController
var index indexController
var rules scopesController
var scopes scopesController
var plugins pluginsController
var instances instancesController

// routes stores the registered routes.
var routes = []*Route{}
Expand Down
10 changes: 5 additions & 5 deletions manager/controller_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ type info struct {
Links map[string]string `json:"links"`
}

// IndexController represents the base routes HTTP controller.
type IndexController struct{}
// indexController represents the base routes HTTP controller.
type indexController struct{}

func (IndexController) Get(ctx *Context) {
func (indexController) Get(ctx *Context) {
hostname, _ := os.Hostname()
links := map[string]string{
"catalog": "/catalog",
Expand All @@ -43,7 +43,7 @@ func (IndexController) Get(ctx *Context) {
})
}

func (IndexController) Catalog(ctx *Context) {
func (indexController) Catalog(ctx *Context) {
rules := []rule.Info{}
for _, rule := range rule.Rules {
rules = append(rules, rule)
Expand All @@ -65,7 +65,7 @@ func (IndexController) Catalog(ctx *Context) {
ctx.Send(catalog)
}

func (IndexController) Manager(ctx *Context) {
func (indexController) Manager(ctx *Context) {
info := struct {
Links map[string]string `json:"links"`
}{
Expand Down
10 changes: 5 additions & 5 deletions manager/controller_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ func createInstances(instances []*Instance) []JSONInstance {
return list
}

// InstancesController represents the rules entity HTTP controller.
type InstancesController struct{}
// instancesController represents the rules entity HTTP controller.
type instancesController struct{}

func (InstancesController) List(ctx *Context) {
func (instancesController) List(ctx *Context) {
ctx.Send(createInstances(ctx.Manager.Instances()))
}

func (InstancesController) Get(ctx *Context) {
func (instancesController) Get(ctx *Context) {
ctx.Send(createInstance(ctx.Instance))
}

func (InstancesController) Delete(ctx *Context) {
func (instancesController) Delete(ctx *Context) {
if ctx.Manager.RemoveInstance(ctx.Instance.ID()) {
ctx.SendNoContent()
} else {
Expand Down
14 changes: 7 additions & 7 deletions manager/controller_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func createPlugin(p plugin.Plugin) JSONPlugin {
}
}

// PluginsController represents the plugins entity HTTP controller.
type PluginsController struct{}
// pluginsController represents the plugins entity HTTP controller.
type pluginsController struct{}

func (PluginsController) List(ctx *Context) {
func (pluginsController) List(ctx *Context) {
var layer *plugin.Layer
if ctx.AdminPlugins != nil {
layer = ctx.AdminPlugins
Expand All @@ -48,19 +48,19 @@ func (PluginsController) List(ctx *Context) {
ctx.Send(createPlugins(layer.All()))
}

func (PluginsController) Get(ctx *Context) {
func (pluginsController) Get(ctx *Context) {
ctx.Send(createPlugin(ctx.Plugin))
}

func (PluginsController) Delete(ctx *Context) {
func (pluginsController) Delete(ctx *Context) {
if ctx.Manager.RemovePlugin(ctx.Plugin.ID()) {
ctx.SendNoContent()
} else {
ctx.SendError(500, "Cannot remove plugin")
}
}

func (p PluginsController) Create(ctx *Context) {
func (p pluginsController) Create(ctx *Context) {
type data struct {
Name string `json:"name"`
Params config.Config `json:"config"`
Expand Down Expand Up @@ -93,7 +93,7 @@ func (p PluginsController) Create(ctx *Context) {
ctx.Send(createPlugin(instance))
}

func (PluginsController) registerPlugin(ctx *Context, instance plugin.Plugin) {
func (pluginsController) registerPlugin(ctx *Context, instance plugin.Plugin) {
if ctx.Scope != nil {
ctx.Scope.UsePlugin(instance)
} else {
Expand Down
12 changes: 6 additions & 6 deletions manager/controller_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ func createRule(rule rule.Rule) JSONRule {
}
}

// RulesController represents the rules entity HTTP controller.
type RulesController struct{}
// rulesController represents the rules entity HTTP controller.
type rulesController struct{}

func (RulesController) List(ctx *Context) {
func (rulesController) List(ctx *Context) {
ctx.Send(createRules(ctx.Scope))
}

func (RulesController) Get(ctx *Context) {
func (rulesController) Get(ctx *Context) {
ctx.Send(createRule(ctx.Rule))
}

func (RulesController) Delete(ctx *Context) {
func (rulesController) Delete(ctx *Context) {
if ctx.Scope.RemoveRule(ctx.Rule.ID()) {
ctx.SendNoContent()
} else {
ctx.SendError(500, "Cannot remove rule")
}
}

func (RulesController) Create(ctx *Context) {
func (rulesController) Create(ctx *Context) {
type data struct {
Name string `json:"name"`
Params config.Config `json:"config"`
Expand Down
12 changes: 6 additions & 6 deletions manager/controller_scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func createScopes(scopes []*Scope) []JSONScope {
return list
}

// ScopesController represents the scopes entity HTTP controller.
type ScopesController struct{}
// scopesController represents the scopes entity HTTP controller.
type scopesController struct{}

func (ScopesController) List(ctx *Context) {
func (scopesController) List(ctx *Context) {
var scopes []*Scope
if ctx.Instance != nil {
scopes = ctx.Instance.Scopes()
Expand All @@ -38,19 +38,19 @@ func (ScopesController) List(ctx *Context) {
ctx.Send(createScopes(scopes))
}

func (ScopesController) Get(ctx *Context) {
func (scopesController) Get(ctx *Context) {
ctx.Send(createScope(ctx.Scope))
}

func (ScopesController) Delete(ctx *Context) {
func (scopesController) Delete(ctx *Context) {
if ctx.Manager.RemoveScope(ctx.Scope.ID) {
ctx.SendNoContent()
} else {
ctx.SendError(500, "Cannot remove scope")
}
}

func (ScopesController) Create(ctx *Context) {
func (scopesController) Create(ctx *Context) {
type data struct {
Name string `json:"name"`
Description string `json:"description"`
Expand Down

0 comments on commit 85de7b8

Please sign in to comment.