api

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 9 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) GetEditedComments added in v2.0.2

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

GetEditedComments handles GET /roots/{root_id}/edited - gets comments that have been edited

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 EchoAdapter

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

EchoAdapter wraps the CommentHandler for Echo framework

func NewEchoAdapter

func NewEchoAdapter(commentService *service.CommentService) *EchoAdapter

NewEchoAdapter creates a new Echo adapter for Commentific

func (*EchoAdapter) CreateComment

func (a *EchoAdapter) CreateComment(c echo.Context) error

func (*EchoAdapter) DeleteComment

func (a *EchoAdapter) DeleteComment(c echo.Context) error

func (*EchoAdapter) GetComment

func (a *EchoAdapter) GetComment(c echo.Context) error

func (*EchoAdapter) GetCommentChildren

func (a *EchoAdapter) GetCommentChildren(c echo.Context) error

func (*EchoAdapter) GetCommentPath

func (a *EchoAdapter) GetCommentPath(c echo.Context) error

func (*EchoAdapter) GetCommentStats

func (a *EchoAdapter) GetCommentStats(c echo.Context) error

func (*EchoAdapter) GetCommentTree

func (a *EchoAdapter) GetCommentTree(c echo.Context) error

func (*EchoAdapter) GetCommentsByRoot

func (a *EchoAdapter) GetCommentsByRoot(c echo.Context) error

func (*EchoAdapter) GetCommentsByUser

func (a *EchoAdapter) GetCommentsByUser(c echo.Context) error

func (*EchoAdapter) GetCommentsWithVotes

func (a *EchoAdapter) GetCommentsWithVotes(c echo.Context) error

func (*EchoAdapter) GetTopComments

func (a *EchoAdapter) GetTopComments(c echo.Context) error

func (*EchoAdapter) GetUserCommentCount

func (a *EchoAdapter) GetUserCommentCount(c echo.Context) error

func (*EchoAdapter) HealthCheck

func (a *EchoAdapter) HealthCheck(c echo.Context) error

func (*EchoAdapter) RegisterRoutes

func (a *EchoAdapter) RegisterRoutes(e *echo.Echo)

RegisterRoutes registers all Commentific routes with an Echo instance

func (*EchoAdapter) RegisterRoutesWithPrefix

func (a *EchoAdapter) RegisterRoutesWithPrefix(e *echo.Echo, prefix string)

RegisterRoutesWithPrefix registers routes with a custom prefix

func (*EchoAdapter) RemoveVote

func (a *EchoAdapter) RemoveVote(c echo.Context) error

func (*EchoAdapter) SearchComments

func (a *EchoAdapter) SearchComments(c echo.Context) error

func (*EchoAdapter) UpdateComment

func (a *EchoAdapter) UpdateComment(c echo.Context) error

func (*EchoAdapter) VoteComment

func (a *EchoAdapter) VoteComment(c echo.Context) error

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

type VoteRequest added in v2.0.2

type VoteRequest struct {
	VoteType models.VoteType `json:"vote_type" validate:"required,oneof=1 -1"`
}

VoteRequest should only contain the vote type

Jump to

Keyboard shortcuts

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