示例#1
0
func New() Handler {
	h := new(Handler)
	h.articles = articles.New()
	h.ItoArticle = baseArticle

	// URLs, Paths
	h.MediaURL = config.RequiredGroupString("articles", "mediaURL")
	h.BasePath = config.RequiredGroupString("articles", "basePath")
	h.ImagePath = config.RequiredGroupString("articles", "imagePath")

	// Templates
	h.Templates = map[string]string{
		"list":   "/articles/articles.html",
		"view":   "/articles/article.html",
		"create": "/articles/create.html",
		"edit":   "/articles/edit.html",
	}

	// Page count
	h.PageCount = 30
	if c, ok := config.GroupInt("articles", "pageCount"); ok {
		h.PageCount = c
	}

	return *h
}
示例#2
0
func Examplerequired_GroupString() {
	// for a `config.json` file like:
	/*
		{
			"host": "google.com",
			"links": {
				"google": "https://google.com"
			}
		}
	*/
	groupHost := config.RequiredGroupString("links", "google")
	fmt.Println(groupHost)
	// Output:
	// https://google.com true
	//
	// panics when not found within `config.json`
}