person.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package libamuse
  2. import (
  3. "notabug.org/apiote/amuse/tmdb"
  4. "notabug.org/apiote/amuse/accounts"
  5. "notabug.org/apiote/gott"
  6. )
  7. func getPerson(args ...interface{}) (interface{}, error) {
  8. data := args[0].(*RequestData)
  9. result := args[1].(*Result)
  10. languages := result.languages
  11. person, err := tmdb.GetPerson(data.id, languages[0].String(), "")
  12. result.result = person
  13. return gott.Tuple(args), err
  14. }
  15. func renderPerson(args ...interface{}) interface{} {
  16. result := args[1].(*Result)
  17. person := result.result.(*tmdb.Person)
  18. result.page = result.renderer.RenderPerson(person, result.languages)
  19. return gott.Tuple(args)
  20. }
  21. func ShowPerson(id, etag, language, mimetype string, auth accounts.Authentication) (string, error) {
  22. auth.Necessary = false
  23. r, err := gott.
  24. NewResult(gott.Tuple{&RequestData{id: id,language: language, mimetype: mimetype, auth: auth}, &Result{}}).
  25. Bind(parseLanguage).
  26. Bind(verifyToken).
  27. Bind(getPerson).
  28. Bind(createRenderer).
  29. Map(renderPerson).
  30. Finish()
  31. if err != nil {
  32. return "", err
  33. } else {
  34. return r.(gott.Tuple)[1].(*Result).page, nil
  35. }
  36. }