Documentation

Index

Constants

This section is empty.

Variables

View Source
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 요청인 경우 바디를 출력.

    Types

    type Authenticator

    type Authenticator struct {
    	UserRepository repository.UserRepositoryInterface
    }

    func (*Authenticator) Authenticate

    func (a *Authenticator) Authenticate(handlerFunc echo.HandlerFunc) echo.HandlerFunc

    func (*Authenticator) KhumuBasicAuth

    func (a *Authenticator) KhumuBasicAuth(username, password string, c echo.Context) (bool, error)

    type CommentResponse

    type CommentResponse struct {
    	Data    *model.Comment `json:"data"` //this contains any format of comments
    	Message string         `json:"message"`
    }

    type CommentRouter

    type CommentRouter struct {
    	*echo.Group
    	UC usecase.CommentUseCaseInterface
    }

    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 CommentsResponse struct {
          	Data    []*model.Comment `json:"data"` //this contains any format of comments
          	Message string           `json:"message"`
          }

          type LikeCommentResponse

          type LikeCommentResponse struct {
          	Data    bool   `json:"data"` //this contains any format of comments
          	Message string `json:"message"`
          }

          type LikeCommentRouter

          type LikeCommentRouter struct {
          	*echo.Group
          	UC usecase.LikeCommentUseCaseInterface
          }

          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

            type RootRouter struct{ *echo.Group }

              의존성 주입시에 root router를 판별하기 위해 임베딩

              func NewRootRouter

              func NewRootRouter(echoServer *echo.Echo, userRepository repository.UserRepositoryInterface) *RootRouter