Documentation
¶
Index ¶
- type ShortLink
- type UrlshortenerServer
- func (s *UrlshortenerServer) HandleCreateShortLink(ct *gin.Context)
- func (s *UrlshortenerServer) HandleDeleteShortLink(ct *gin.Context)
- func (s *UrlshortenerServer) HandleGetShortLink(ct *gin.Context)
- func (s *UrlshortenerServer) HandleListShortLink(ct *gin.Context)
- func (s *UrlshortenerServer) HandleShortLink(ct *gin.Context)
- func (s *UrlshortenerServer) HandleUpdateShortLink(ct *gin.Context)
- func (s *UrlshortenerServer) Load()
- func (s *UrlshortenerServer) Serve(addr string) humane.Error
- func (s *UrlshortenerServer) ServeAsync(addr string)
- func (s *UrlshortenerServer) Shutdown(ctx context.Context) humane.Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ShortLink ¶
type ShortLink struct {
Name string `json:"name"`
Spec v1alpha1.ShortLinkSpec `json:"spec,omitempty"`
Status v1alpha1.ShortLinkStatus `json:"status,omitempty"`
}
type UrlshortenerServer ¶
type UrlshortenerServer struct {
// contains filtered or unexported fields
}
func NewGinGonicHTTPServer ¶
func NewGinGonicHTTPServer(client *shortlinkClient.ShortlinkClient) *UrlshortenerServer
NewGinGonicHTTPServer creates a new urlshortener API Server
func (*UrlshortenerServer) HandleCreateShortLink ¶
func (s *UrlshortenerServer) HandleCreateShortLink(ct *gin.Context)
HandleCreateShortLink handles the creation of a shortlink and redirects according to the configuration @BasePath /api/v1/ @Summary create new shortlink @Schemes http https @Description create a new shortlink @Accept application/json @Produce text/plain @Produce application/json @Param shortlink path string false "the shortlink URL part (shortlink id)" example(home) @Param spec body v1alpha1.ShortLinkSpec true "shortlink spec" @Success 200 {object} int "Success" @Success 301 {object} int "MovedPermanently" @Success 302 {object} int "Found" @Success 307 {object} int "TemporaryRedirect" @Success 308 {object} int "PermanentRedirect" @Failure 401 {object} int "Unauthorized" @Failure 404 {object} int "NotFound" @Failure 500 {object} int "InternalServerError" @Tags api/v1/ @Router /api/v1/shortlink/{shortlink} [post] @Security bearerAuth
func (*UrlshortenerServer) HandleDeleteShortLink ¶
func (s *UrlshortenerServer) HandleDeleteShortLink(ct *gin.Context)
HandleDeleteShortLink handles the deletion of a shortlink @BasePath /api/v1/ @Summary delete shortlink @Schemes http https @Description delete shortlink @Produce text/plain @Produce application/json @Param shortlink path string true "the shortlink URL part (shortlink id)" example(home) @Success 200 {object} int "Success" @Failure 401 {object} int "Unauthorized" @Failure 404 {object} int "NotFound" @Failure 500 {object} int "InternalServerError" @Tags api/v1/ @Router /api/v1/shortlink/{shortlink} [delete] @Security bearerAuth
func (*UrlshortenerServer) HandleGetShortLink ¶
func (s *UrlshortenerServer) HandleGetShortLink(ct *gin.Context)
HandleGetShortLink returns the shortlink @BasePath /api/v1/ @Summary get a shortlink @Schemes http https @Description get a shortlink @Produce text/plain @Produce application/json @Param shortlink path string false "the shortlink URL part (shortlink id)" example(home) @Success 200 {object} ShortLink "Success" @Failure 401 {object} int "Unauthorized" @Failure 404 {object} int "NotFound" @Failure 500 {object} int "InternalServerError" @Tags api/v1/ @Router /api/v1/shortlink/{shortlink} [get] @Security bearerAuth
func (*UrlshortenerServer) HandleListShortLink ¶
func (s *UrlshortenerServer) HandleListShortLink(ct *gin.Context)
HandleListShortLink handles the listing of @BasePath /api/v1/ @Summary list shortlinks @Schemes http https @Description list shortlinks @Produce text/plain @Produce application/json @Success 200 {object} []ShortLink "Success" @Failure 401 {object} int "Unauthorized" @Failure 404 {object} int "NotFound" @Failure 500 {object} int "InternalServerError" @Tags api/v1/ @Router /api/v1/shortlink/ [get] @Security bearerAuth
func (*UrlshortenerServer) HandleShortLink ¶
func (s *UrlshortenerServer) HandleShortLink(ct *gin.Context)
HandleShortLink handles the shortlink and redirects according to the configuration @BasePath / @Summary redirect to target @Schemes http https @Description redirect to target as per configuration of the shortlink @Produce text/html @Param shortlink path string true "shortlink id" @Success 200 {object} int "Success" @Success 300 {object} int "MultipleChoices" @Success 301 {object} int "MovedPermanently" @Success 302 {object} int "Found" @Success 303 {object} int "SeeOther" @Success 304 {object} int "NotModified" @Success 305 {object} int "UseProxy" @Success 307 {object} int "TemporaryRedirect" @Success 308 {object} int "PermanentRedirect" @Failure 404 {object} int "NotFound" @Failure 500 {object} int "InternalServerError" @Tags default @Router /{shortlink} [get]
func (*UrlshortenerServer) HandleUpdateShortLink ¶
func (s *UrlshortenerServer) HandleUpdateShortLink(ct *gin.Context)
HandleUpdateShortLink handles the update of a shortlink @BasePath /api/v1/ @Summary update existing shortlink @Schemes http https @Description update a new shortlink @Accept application/json @Produce text/plain @Produce application/json @Param shortlink path string true "the shortlink URL part (shortlink id)" example(home) @Param spec body v1alpha1.ShortLinkSpec true "shortlink spec" @Success 200 {object} int "Success" @Failure 401 {object} int "Unauthorized" @Failure 404 {object} int "NotFound" @Failure 500 {object} int "InternalServerError" @Tags api/v1/ @Router /api/v1/shortlink/{shortlink} [put] @Security bearerAuth
func (*UrlshortenerServer) Load ¶
func (s *UrlshortenerServer) Load()
func (*UrlshortenerServer) ServeAsync ¶
func (s *UrlshortenerServer) ServeAsync(addr string)