Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthRequest ¶
type AuthRequest struct { Username string `json:"username" example:"test@example.com"` Password string `json:"password" example:"mycoolpassword123"` }
func (*AuthRequest) IsValid ¶
func (r *AuthRequest) IsValid() error
type AuthResponse ¶
type AuthResponse struct {
AccessToken string `json:"accessToken"`
}
type GenericResponse ¶
type GenericResponse struct { Message string `json:"message"` Data interface{} `json:"data"` }
func GenericError ¶
func GenericError(message string) GenericResponse
type Handler ¶
type Handler struct { Config config.HTTPConfig Usecase IUsecase }
func (*Handler) Auth ¶
func (h *Handler) Auth(w http.ResponseWriter, r *http.Request)
Auth godoc @Summary Request to issue access token @Tags auth @Accept json @Produce json @Param data body AuthRequest true "Input model" @Success 200 {object} AuthResponse @Failure 401 {object} GenericResponse @Failure 400 {object} GenericResponse @Failure 500 {object} GenericResponse @Router /api/auth [Post] @BasePath /
func (*Handler) GetLink ¶
func (h *Handler) GetLink(w http.ResponseWriter, r *http.Request)
GetLink godoc @Summary Go to original url @Tags link @Accept json @Produce json @Param short path string true "short relative url" @Success 302 @Failure 404 @Failure 500 @Router /{short} [Get] @BasePath /
func (*Handler) PutLink ¶
func (h *Handler) PutLink(w http.ResponseWriter, r *http.Request)
PutLink godoc @Summary Create new short link @Tags link @Accept json @Produce json @Param Authorization header string true "Bearer token" @Param data body PutLinkRequest true "Input model" @Success 200 {object} PutLinkResponse @Failure 401 {object} GenericResponse @Failure 400 {object} GenericResponse @Failure 500 {object} GenericResponse @Router /api/link [Put] @BasePath /
type PutLinkRequest ¶
type PutLinkRequest struct {
OriginalURL string `json:"originalURL" example:"https://example.com/page1?id=3"`
}
func (*PutLinkRequest) IsValid ¶
func (r *PutLinkRequest) IsValid() error
type PutLinkResponse ¶
type PutLinkResponse struct {
ShortURL string `json:"shortURL" example:"https://caurlshortener.com/128hbcddhs712"`
}