Ejemplo n.º 1
0
func (o *SimpleToDoListAPI) initHandlerCache() {
	if o.context == nil {
		o.context = middleware.NewRoutableContext(o.spec, o, nil)
	}

	if o.handlers == nil {
		o.handlers = make(map[string]map[string]http.Handler)
	}

	if o.handlers["POST"] == nil {
		o.handlers[strings.ToUpper("POST")] = make(map[string]http.Handler)
	}
	o.handlers["POST"]["/"] = todos.NewAddOne(o.context, o.TodosAddOneHandler)

	if o.handlers["DELETE"] == nil {
		o.handlers[strings.ToUpper("DELETE")] = make(map[string]http.Handler)
	}
	o.handlers["DELETE"]["/{id}"] = todos.NewDestroyOne(o.context, o.TodosDestroyOneHandler)

	if o.handlers["GET"] == nil {
		o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
	}
	o.handlers["GET"]["/"] = todos.NewFind(o.context, o.TodosFindHandler)

	if o.handlers["PUT"] == nil {
		o.handlers[strings.ToUpper("PUT")] = make(map[string]http.Handler)
	}
	o.handlers["PUT"]["/{id}"] = todos.NewUpdateOne(o.context, o.TodosUpdateOneHandler)

}
Ejemplo n.º 2
0
func (o *ToDoListAPI) initHandlerCache() {
	if o.context == nil {
		o.context = middleware.NewRoutableContext(o.spec, o, nil)
	}

	o.handlers = make(map[string]http.Handler)

	o.handlers["addOne"] = todos.NewAddOne(o.context, o.AddOneHandler)

	o.handlers["destroyOne"] = todos.NewDestroyOne(o.context, o.DestroyOneHandler)

	o.handlers["find"] = todos.NewFind(o.context, o.FindHandler)

	o.handlers["updateOne"] = todos.NewUpdateOne(o.context, o.UpdateOneHandler)

}