Exemple #1
0
// Set page title and related meta tags
func Title(t string) server.PageInstanceHandler {
	return server.PageInstanceHandler(func(req *wcg.Request, pr *response.PageResponse) *response.PageResponse {
		pr.Title = t
		pr.OGP.Set("og:title", t)
		return pr
	})
}
Exemple #2
0
func MemberPageHandler(handlers ...func(*wcg.Request, *response.PageResponse, *hplink.Member) *response.PageResponse) server.PageInstanceHandler {
	return server.PageInstanceHandler(func(req *wcg.Request, pr *response.PageResponse) *response.PageResponse {
		member := findArtistAndMember(req)
		if member == nil {
			pr.StatusCode = 404
			return pr
		}
		for _, h := range handlers {
			pr = h(req, pr, member)
			if pr.StatusCode >= 200 && pr.StatusCode < 300 {
				break
			}
		}
		return pr
	})
}
Exemple #3
0
func ArtistPageHandler(handlers ...func(*wcg.Request, *response.PageResponse, *hplink.Artist) *response.PageResponse) server.PageInstanceHandler {
	return server.PageInstanceHandler(func(req *wcg.Request, pr *response.PageResponse) *response.PageResponse {
		artistKey := req.Param(paramKeyArtist)
		if artistKey == "" {
			panic("[BUG] :artist is not found in URL path.")
		}
		_, ent := entities.Artist.Get().Key(artistKey).MustOne(req)
		if ent == nil {
			return response.PageNotFound
		}
		artist := ent.(*hplink.Artist)
		for _, h := range handlers {
			pr = h(req, pr, artist)
			if pr.StatusCode >= 200 && pr.StatusCode < 300 {
				break
			}
		}
		return pr
	})
}