Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorForbidden = Response{Code: http.StatusForbidden, Message: "Forbidden"} ErrorRequiredField = Response{Code: http.StatusBadRequest, Message: "Required field"} ErrorInternal = Response{Code: http.StatusInternalServerError, Message: "Internal Server Error"} ErrorBadRequest = Response{Code: http.StatusBadRequest, Message: "Bad Request"} ErrorNoRecords = Response{Code: http.StatusOK, Message: "No records found"} ErrorNotFound = Response{Code: http.StatusNotFound, Message: "No records found"} )
View Source
var ( SuccessCreateResponse = Response{Code: 200, Message: "Post created successfully"} SuccessCreateCommentResponse = Response{Code: 200, Message: "Comment created successfully"} SuccessListResponse = Response{Code: 200, Message: "Posts fetched successfully"} )
Functions ¶
This section is empty.
Types ¶
type CreatePostCommentPayload ¶
type CreatePostCommentPayload struct { UserID string PostID string `json:"postId"` Comment string `json:"comment"` }
func (CreatePostCommentPayload) Validate ¶
func (p CreatePostCommentPayload) Validate() error
type CreatePostPayload ¶
type CreatePostPayload struct { UserID string PostInHTML string `json:"postInHtml"` Tags []string `json:"tags"` }
func (CreatePostPayload) Validate ¶
func (p CreatePostPayload) Validate() error
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) CreatePost ¶
func (h *Handler) CreatePost(w http.ResponseWriter, r *http.Request)
func (*Handler) CreatePostComment ¶
func (h *Handler) CreatePostComment(w http.ResponseWriter, r *http.Request)
type ListPostPayload ¶
type ListPostResponse ¶
type ListPostResponse struct { PostID string `json:"postId"` Post PostResponse `json:"post"` Comments []comments.CommentResponse `json:"comments"` User user.UserGetResponse `json:"creator"` }
type PostResponse ¶
type Repository ¶
type Repository interface { Create(ctx context.Context, post *Posts) error GetByID(ctx context.Context, id string) (*Posts, error) CreateComment(ctx context.Context, comment *Comment) error List(ctx context.Context, filter ListPostPayload) ([]ListPostResponse, *response.Pagination, error) }
func NewRepository ¶
func NewRepository(db *db.DB) Repository
type Service ¶
type Service interface { Create(ctx context.Context, req CreatePostPayload) Response CreatePostComment(ctx context.Context, req CreatePostCommentPayload) Response List(ctx context.Context, req ListPostPayload) Response }
func NewService ¶
func NewService(repository Repository, userFriendsRepository userfriends.Repository) Service
Click to show internal directories.
Click to hide internal directories.