api

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(commentService *service.CommentService) *mux.Router

Router sets up and returns the HTTP router with all endpoints

Types

type APIResponse

type APIResponse struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
	Message string      `json:"message,omitempty"`
}

APIResponse represents a standard API response

type CommentHandler

type CommentHandler struct {
	// contains filtered or unexported fields
}

CommentHandler handles HTTP requests for comment operations

func NewCommentHandler

func NewCommentHandler(commentService *service.CommentService) *CommentHandler

NewCommentHandler creates a new comment handler

func (*CommentHandler) CreateComment

func (h *CommentHandler) CreateComment(w http.ResponseWriter, r *http.Request)

CreateComment handles POST /comments

func (*CommentHandler) DeleteComment

func (h *CommentHandler) DeleteComment(w http.ResponseWriter, r *http.Request)

DeleteComment handles DELETE /comments/{id}

func (*CommentHandler) GetComment

func (h *CommentHandler) GetComment(w http.ResponseWriter, r *http.Request)

GetComment handles GET /comments/{id}

func (*CommentHandler) GetCommentChildren

func (h *CommentHandler) GetCommentChildren(w http.ResponseWriter, r *http.Request)

GetCommentChildren handles GET /comments/{id}/children

func (*CommentHandler) GetCommentPath

func (h *CommentHandler) GetCommentPath(w http.ResponseWriter, r *http.Request)

GetCommentPath handles GET /comments/{id}/path

func (*CommentHandler) GetCommentStats

func (h *CommentHandler) GetCommentStats(w http.ResponseWriter, r *http.Request)

GetCommentStats handles GET /roots/{root_id}/stats

func (*CommentHandler) GetCommentTree

func (h *CommentHandler) GetCommentTree(w http.ResponseWriter, r *http.Request)

GetCommentTree handles GET /roots/{root_id}/tree

func (*CommentHandler) GetCommentsByRoot

func (h *CommentHandler) GetCommentsByRoot(w http.ResponseWriter, r *http.Request)

GetCommentsByRoot handles GET /roots/{root_id}/comments

func (*CommentHandler) GetCommentsByUser

func (h *CommentHandler) GetCommentsByUser(w http.ResponseWriter, r *http.Request)

GetCommentsByUser handles GET /users/{user_id}/comments

func (*CommentHandler) GetCommentsWithVotes

func (h *CommentHandler) GetCommentsWithVotes(w http.ResponseWriter, r *http.Request)

GetCommentsWithVotes handles GET /roots/{root_id}/comments/with-votes

func (*CommentHandler) GetTopComments

func (h *CommentHandler) GetTopComments(w http.ResponseWriter, r *http.Request)

GetTopComments handles GET /roots/{root_id}/top

func (*CommentHandler) GetUserCommentCount

func (h *CommentHandler) GetUserCommentCount(w http.ResponseWriter, r *http.Request)

GetUserCommentCount handles GET /users/{user_id}/count

func (*CommentHandler) RemoveVote

func (h *CommentHandler) RemoveVote(w http.ResponseWriter, r *http.Request)

RemoveVote handles DELETE /comments/{id}/vote

func (*CommentHandler) SearchComments

func (h *CommentHandler) SearchComments(w http.ResponseWriter, r *http.Request)

SearchComments handles GET /roots/{root_id}/search

func (*CommentHandler) UpdateComment

func (h *CommentHandler) UpdateComment(w http.ResponseWriter, r *http.Request)

UpdateComment handles PUT /comments/{id}

func (*CommentHandler) VoteComment

func (h *CommentHandler) VoteComment(w http.ResponseWriter, r *http.Request)

VoteComment handles POST /comments/{id}/vote

type PaginatedResponse

type PaginatedResponse struct {
	Success    bool        `json:"success"`
	Data       interface{} `json:"data"`
	Pagination *Pagination `json:"pagination,omitempty"`
	Error      string      `json:"error,omitempty"`
}

PaginatedResponse represents a paginated API response

type Pagination

type Pagination struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
	Total  int `json:"total,omitempty"`
}

Pagination represents pagination metadata

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL