Documentation ¶
Index ¶
- func RenderAccount(w http.ResponseWriter, r *http.Request, user *models.User)
- func RenderBlankResponse(w http.ResponseWriter, r *http.Request)
- func RenderCategories(w http.ResponseWriter, r *http.Request, categories []*models.Category)
- func RenderCategory(w http.ResponseWriter, r *http.Request, category *models.Category)
- func RenderComment(w http.ResponseWriter, r *http.Request, comment *models.Comment)
- func RenderComments(w http.ResponseWriter, r *http.Request, comments []*models.Comment)
- func RenderErrorResponse(w http.ResponseWriter, r *http.Request, err error)
- func RenderResponse(w http.ResponseWriter, r *http.Request, data interface{})
- func RenderTopic(w http.ResponseWriter, r *http.Request, topic *models.Topic)
- func RenderTopics(w http.ResponseWriter, r *http.Request, topics []*models.Topic)
- func RenderUser(w http.ResponseWriter, r *http.Request, user *models.User)
- func RenderUsers(w http.ResponseWriter, r *http.Request, users []*models.User)
- type AccountView
- type CategoryView
- type CommentView
- type ResponseView
- type TopicView
- type UserView
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderAccount ¶
RenderAccount response
func RenderBlankResponse ¶
func RenderBlankResponse(w http.ResponseWriter, r *http.Request)
RenderBlankResponse respond a blank response
func RenderCategories ¶
RenderCategories response sevaral categories
func RenderCategory ¶
RenderCategory response a category
func RenderComment ¶
RenderComment response a comment
func RenderComments ¶
RenderComments response a bundle of comments
func RenderErrorResponse ¶
func RenderErrorResponse(w http.ResponseWriter, r *http.Request, err error)
RenderErrorResponse respond an error response
func RenderResponse ¶
func RenderResponse(w http.ResponseWriter, r *http.Request, data interface{})
RenderResponse respond a special data, e.g.: Topic, Category etc.
func RenderTopic ¶
RenderTopic response a topic
func RenderTopics ¶
RenderTopics response a bundle of topics
func RenderUser ¶
RenderUser response a user
func RenderUsers ¶
RenderUsers response a bundle of users
Types ¶
type AccountView ¶
type AccountView struct { UserView Username string `json:"username"` Email string `json:"email"` SessionID string `json:"session_id"` Role string `json:"role"` }
AccountView is the response body of a sign in user
type CategoryView ¶
type CategoryView struct { Type string `json:"type"` CategoryID string `json:"category_id"` Name string `json:"name"` Alias string `json:"alias"` Description string `json:"description"` TopicsCount int64 `json:"topics_count"` LastTopicID string `json:"last_topic_id"` Position int64 `json:"position"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
CategoryView is the response body of a category
type CommentView ¶
type CommentView struct { CommentID string `json:"comment_id,pk"` Body string `json:"body"` TopicID string `json:"topic_id"` UserID string `json:"user_id"` Score int `json:"score,notnull"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` User UserView `json:"user"` }
CommentView is the response body of comment
type ResponseView ¶
type ResponseView struct { Data interface{} `json:"data,omitempty"` Error error `json:"error,omitempty"` }
ResponseView is the struct of response
type TopicView ¶
type TopicView struct { Type string `json:"type"` TopicID string `json:"topic_id"` Title string `json:"title"` Body string `json:"body"` UserID string `json:"user_id"` CategoryID string `json:"category_id"` Score int `json:"score"` CommentsCount int64 `json:"comments_count"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` User UserView `json:"user"` Category CategoryView `json:"category"` }
TopicView is the response body of topic
type UserView ¶
type UserView struct { Type string `json:"type"` UserID string `json:"user_id"` Nickname string `json:"nickname"` Biography string `json:"biography"` AvatarURL string `json:"avatar_url"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
UserView is the response body of user