Documentation
Index ¶
- Variables
- func KhumuRequestLog(handlerFunc echo.HandlerFunc) echo.HandlerFunc
- func NewEcho(userRepository repository.UserRepositoryInterface, ...) *echo.Echo
- type Authenticator
- type CommentResponse
- type CommentRouter
- type CommentsResponse
- type LikeCommentResponse
- type LikeCommentRouter
- type RootRouter
Constants ¶
Variables ¶
var KhumuJWTConfig middleware.JWTConfig = middleware.JWTConfig{ Skipper: func(c echo.Context) bool { return false }, SigningKey: []byte(os.Getenv("KHUMU_SECRET")), SigningMethod: "HS256", ContextKey: "user", TokenLookup: "header:" + echo.HeaderAuthorization, AuthScheme: "Bearer", Claims: jwt.MapClaims{}, }
Functions ¶
func KhumuRequestLog ¶
func KhumuRequestLog(handlerFunc echo.HandlerFunc) echo.HandlerFunc
application/json 요청인 경우 바디를 출력.
func NewEcho ¶
func NewEcho(userRepository repository.UserRepositoryInterface, commentUC usecase.CommentUseCaseInterface, likeUC usecase.LikeCommentUseCaseInterface) *echo.Echo
Types ¶
type Authenticator ¶
type Authenticator struct {
UserRepository repository.UserRepositoryInterface
}
func (*Authenticator) Authenticate ¶
func (a *Authenticator) Authenticate(handlerFunc echo.HandlerFunc) echo.HandlerFunc
func (*Authenticator) KhumuBasicAuth ¶
type CommentResponse ¶
type CommentRouter ¶
type CommentRouter struct { *echo.Group UC usecase.CommentUseCaseInterface }
func NewCommentRouter ¶
func NewCommentRouter(root *RootRouter, uc usecase.CommentUseCaseInterface) *CommentRouter
func (*CommentRouter) Create ¶
func (r *CommentRouter) Create(c echo.Context) error
@Tags Comment @Summary Comment를 생성합니다. @Description 사용 가능한 필드는 주로 Get API의 응답에 있는 필드와 유사합니다. @Description author field는 요청자의 Authorization header의 값을 이용합니다. @name create-comment @Accept application/json @Produce application/json @Param article body int true "어떤 게시물의 댓글인지" @Param kind body string false "익명인지, 기명인지" @Param content body string true "댓글 내용" @Router /api/comments [post] @Success 200 {object} CommentResponse
func (*CommentRouter) Get ¶
func (r *CommentRouter) Get(c echo.Context) error
@Tags Comment @Summary Comment 조회합니다. @Description @name get-comment @Produce application/json @Param id path int true "Comment ID" @Router /api/comments/{id} [get] @Success 200 {object} CommentResponse
func (*CommentRouter) List ¶
func (r *CommentRouter) List(c echo.Context) error
@Tags comment @Summary Comment List를 조회합니다. @Description @name list-comment @Produce application/json @Param article query int true "admin group이 아닌 이상은 게시물 id를 꼭 정의해야합니다." @Router /api/comments [get] @Success 200 {object} CommentsResponse
type CommentsResponse ¶
type LikeCommentResponse ¶
type LikeCommentRouter ¶
type LikeCommentRouter struct { *echo.Group UC usecase.LikeCommentUseCaseInterface }
func NewLikeCommentRouter ¶
func NewLikeCommentRouter(root *RootRouter, uc usecase.LikeCommentUseCaseInterface) *LikeCommentRouter
func (*LikeCommentRouter) Toggle ¶
func (r *LikeCommentRouter) Toggle(c echo.Context) error
@Tags Like Comment @Summary Comment에 대한 "좋아요"를 생성하거나 삭제합니다. @Description 현재 좋아요 상태이면 삭제, 좋아요 상태가 아니면 생성합니다. @name create-like-comment @Produce application/json @Param comment body int true "좋아요할 comment의 ID" @Router /api/like-comments [put] @Success 200 {object} CommentResponse
type RootRouter ¶
의존성 주입시에 root router를 판별하기 위해 임베딩
func NewRootRouter ¶
func NewRootRouter(echoServer *echo.Echo, userRepository repository.UserRepositoryInterface) *RootRouter