示例#1
0
// Sets the ParameterContext which contains GET/POST data.
// Also sets up the template rendering for this application.
func (ac *App) SetContext(context *filters.DevContext) error {
	if context == nil {
		return errors.New("No context was supplied to this controller!")
	}

	ac.Out = web.NewMustacheRenderer("app/admin/views")
	ac.Dev = context

	return nil
}
示例#2
0
文件: user.go 项目: frazy/babou
package controllers

import (
	"github.com/drbawb/babou/app/filters"
	"github.com/drbawb/babou/app/models"

	"errors"
	"fmt"
	"github.com/drbawb/babou/lib/web"
	"strconv"
)

var renderer web.Renderer = web.NewMustacheRenderer("app/admin/views")

type UsersController struct {
	*App
	Auth *filters.AuthContext
}

func (au *UsersController) Dispatch(action, accept string) (web.Controller, web.Action) {
	newAu := &UsersController{}
	newAu.App = &App{}

	switch action {
	case "index":
		return newAu, newAu.Index
	case "delete":
		return newAu, newAu.Delete
	}

	panic("unreachable")