v1

package
v0.0.0-...-96f74f2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	R string `json:"error"`
}

ErrorResponse is the typical error response. This structure is used for swagger documentation.

type Handler

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

func NewHandler

func NewHandler(service *service.Services) *Handler

func (*Handler) ActivateUserHandler

func (h *Handler) ActivateUserHandler(w http.ResponseWriter, r *http.Request)

ActivateUserHandler activates the user by input token

@Summary Activation @Description Activates the user by input token. @Tags users @Accept json @Produce json @Param body body service.ActivateUserInput true "User activation input" @Success 202 {object} service.UserResp "Successfully accepted" @Failure 400 {object} ErrorResponse "Bad request" @Failure 422 {object} ErrorResponse "Unprocessable data" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/users/activated [put]

func (*Handler) Authenticate

func (h *Handler) Authenticate(next http.Handler) http.Handler

func (*Handler) AuthenticationRequiredResponse

func (h *Handler) AuthenticationRequiredResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) BadRequestResponse

func (h *Handler) BadRequestResponse(w http.ResponseWriter, r *http.Request, err error)

func (*Handler) CreateAuthenticationTokenHandler

func (h *Handler) CreateAuthenticationTokenHandler(w http.ResponseWriter, r *http.Request)

CreateAuthenticationTokenHandler creates a new authentication token by input data

@Summary Authentication @Description Creates a new user token in the database by input data. @Tags users @Tags tokens @Accept json @Produce json @Param body body service.AuthInput true "User registration input" @Success 201 {object} service.AuthResp "Successfully created" @Failure 400 {object} ErrorResponse "Bad request" @Failure 401 {object} ErrorResponse "Unauthorized" @Failure 422 {object} ErrorResponse "Unprocessable data" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/tokens/authentication [post]

func (*Handler) CreatePasteHandler

func (h *Handler) CreatePasteHandler(w http.ResponseWriter, r *http.Request)

CreatePasteHandler creates a new paste by input data

@Summary Create a new paste @Description Creates a new paste in the database by input data. @Tags pastes @Accept json @Produce json @Param body body service.CreatePasteInput true "Paste creation input" @Security BearerAuth @Success 201 {object} service.PasteResp "Successfully created paste" @Header 201 {string} Location "URL of the newly created paste" @Failure 400 {object} ErrorResponse "Bad request" @Failure 422 {object} ErrorResponse "Unprocessable data" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/pastes/ [post]

func (*Handler) DebugRequest

func (h *Handler) DebugRequest(next http.Handler) http.Handler

func (*Handler) DeletePasteHandler

func (h *Handler) DeletePasteHandler(w http.ResponseWriter, r *http.Request)

DeletePasteHandler deletes a paste by its ID

@Summary Deletes a paste @Description Deletes a paste from the database by its ID. @Tags pastes @Produce json @Security BearerAuth @Param id path int true "Paste ID" @Success 204 "Successfully deleted paste" @Failure 403 {object} ErrorResponse "User is not allowed to edit this paste" @Failure 404 {object} ErrorResponse "Paste not found" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/pastes/{id} [delete]

func (*Handler) EditConflictResponse

func (h *Handler) EditConflictResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) EnableCORS

func (h *Handler) EnableCORS(next http.Handler) http.Handler

func (*Handler) ErrorResponse

func (h *Handler) ErrorResponse(w http.ResponseWriter, r *http.Request, status int, message interface{})

func (*Handler) FailedValidationResponse

func (h *Handler) FailedValidationResponse(w http.ResponseWriter, r *http.Request, errors map[string]string)

func (*Handler) ForbiddenResponse

func (h *Handler) ForbiddenResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) GetLoggedUserData

func (h *Handler) GetLoggedUserData(w http.ResponseWriter, r *http.Request)

GetLoggedUserData retrieves the logged user data

@Summary Logged user data @Description Retrieves the logged user data. @Tags users @Produce json @Security BearerAuth @Success 200 {object} service.UserResp "Successfully retrieved user data" @Failure 401 {object} ErrorResponse "User is not authorized" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/users/ [GET]

func (*Handler) GetPasteHandler

func (h *Handler) GetPasteHandler(w http.ResponseWriter, r *http.Request)

GetPasteHandler retrieves a paste by its ID

@Summary Retrieve a paste @Description Retrieves a paste from the database by its ID. @Tags pastes @Produce json @Param id path int true "Paste ID" @Success 200 {object} service.PasteResp "Successfully retrieved paste" @Failure 404 {object} ErrorResponse "Paste not found" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/pastes/{id} [get]

func (*Handler) HealthcheckHandler

func (h *Handler) HealthcheckHandler(w http.ResponseWriter, r *http.Request)

HealthcheckHandler retrieves status of the application

@Summary Health check @Description Retrieves status of the application @Tags app @Produce json @Success 200 {object} HealthCheckOutput "Successfully retrieved paste" @Failure 429 {object} v1.ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/healthcheck [get]

func (*Handler) InactiveAccountResponse

func (h *Handler) InactiveAccountResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) InvalidAuthenticationTokenResponse

func (h *Handler) InvalidAuthenticationTokenResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) InvalidCredentialsResponse

func (h *Handler) InvalidCredentialsResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) ListPastesHandler

func (h *Handler) ListPastesHandler(w http.ResponseWriter, r *http.Request)

ListPastesHandler retrieves a paste by its ID

@Summary Retrieve a paste @Description Retrieves a paste from the database by its ID. @Tags pastes @Produce json @Param title query string false "Title of the paste" @Param category query int false "Category ID of the paste" @Param onlyUsers query bool false "Get pastes, which current user can update" @Param sort query string false "Sort order, e.g., -created_at" @Param page query int false "Page number for pagination" @Param pageSize query int false "Number of items per page" @Success 200 {object} service.ListPastesOutput "Successfully retrieved paste" @Failure 422 {object} ErrorResponse "Unprocessing data" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/pastes/ [get]

func (*Handler) LogError

func (h *Handler) LogError(r *http.Request, err error)

func (*Handler) MethodNotAllowedResponse

func (h *Handler) MethodNotAllowedResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) Metrics

func (h *Handler) Metrics(next http.Handler) http.Handler

func (*Handler) NotFoundResponse

func (h *Handler) NotFoundResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) PasswordResetTokenHandler

func (h *Handler) PasswordResetTokenHandler(w http.ResponseWriter, r *http.Request)

PasswordResetTokenHandler creates a new password reset token by input email

@Summary Password reset @Description Creates a new password reset token in the database by input email. Sends a reset password email. @Tags users @Tags tokens @Accept json @Produce json @Param body body service.ResetPasswordInput true "Input email" @Success 202 {object} service.MessageResp "Successfully accepted" @Failure 400 {object} ErrorResponse "Bad request" @Failure 422 {object} ErrorResponse "Unprocessable data" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/tokens/password-reset [post]

func (*Handler) PermissionHandler

func (h *Handler) PermissionHandler(w http.ResponseWriter, r *http.Request)

PermissionHandler gives a write permission by input data

@Summary Gives a write permission @Description Gives a permission to user in the url to update / delete paste in the url. @Tags pastes @Tags users @Produce json @Param id path int true "Paste ID" @Param userLogin path string true "User ID" @Security BearerAuth @Header 200 {string} Location "URL of the newly created paste" @Success 200 {object} service.PastePermissionResponse "Successfully gave permission" @Failure 404 {object} ErrorResponse "Not found" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/pastes/{id}/permission/{userLogin} [put]

func (*Handler) RateLimit

func (h *Handler) RateLimit(next http.Handler) http.Handler

func (*Handler) RateLimitExceededResponse

func (h *Handler) RateLimitExceededResponse(w http.ResponseWriter, r *http.Request)

func (*Handler) RecoverPanic

func (h *Handler) RecoverPanic(next http.Handler) http.Handler

func (*Handler) RegisterUserHandler

func (h *Handler) RegisterUserHandler(w http.ResponseWriter, r *http.Request)

RegisterUserHandler creates a new user by input data

@Summary Registration @Description Creates a new user in the database by input data. @Tags users @Accept json @Produce json @Param body body service.RegistrationInput true "User registration input" @Success 202 {object} service.UserResp "Successfully accepted" @Failure 400 {object} ErrorResponse "Bad request" @Failure 422 {object} ErrorResponse "Unprocessable data" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/users/ [post]

func (*Handler) RequireActivatedUser

func (h *Handler) RequireActivatedUser(next http.HandlerFunc) http.HandlerFunc

func (*Handler) RequireAllowedToWriteUser

func (h *Handler) RequireAllowedToWriteUser(next http.HandlerFunc) http.HandlerFunc

func (*Handler) RequireAuthenticatedUser

func (h *Handler) RequireAuthenticatedUser(next http.HandlerFunc) http.HandlerFunc

func (*Handler) ResendActivationEmail

func (h *Handler) ResendActivationEmail(w http.ResponseWriter, r *http.Request)

ResendActivationEmail activates the user by input token

@Summary Activation @Description Activates the user by input token. @Tags users @Produce json @Success 200 {object} service.MessageResp "Successfully resent" @Failure 400 {object} ErrorResponse "Bad request" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/users/activation-email [post]

func (*Handler) ServerErrorResponse

func (h *Handler) ServerErrorResponse(w http.ResponseWriter, r *http.Request, err error)

func (*Handler) UpdatePasswordHandler

func (h *Handler) UpdatePasswordHandler(w http.ResponseWriter, r *http.Request)

UpdatePasswordHandler updates user's password by input token

@Summary Update password @Description Update user's password by input data. @Tags users @Accept json @Produce json @Param body body service.UpdatePasswordInput true "User activation input" @Success 200 {object} service.MessageResp "Successfully reset" @Failure 400 {object} ErrorResponse "Bad request" @Failure 422 {object} ErrorResponse "Unprocessable data" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/users/password [put]

func (*Handler) UpdatePasteHandler

func (h *Handler) UpdatePasteHandler(w http.ResponseWriter, r *http.Request)

UpdatePasteHandler updates a new paste by ID and input data

@Summary Update the paste @Description Updates the paste in the database by ID and input data. @Tags pastes @Accept json @Produce json @Param id path int true "Paste ID" @Param body body service.UpdatePasteInput false "Paste update input" @Security BearerAuth @Success 200 {object} service.PasteResp "Successfully updated paste" @Failure 400 {object} ErrorResponse "Bad request" @Failure 403 {object} ErrorResponse "User is not allowed to edit this paste" @Failure 404 {object} ErrorResponse "Not found" @Failure 409 {object} ErrorResponse "Conflict" @Failure 422 {object} ErrorResponse "Unprocessable data" @Failure 429 {object} ErrorResponse "Too many requests, rate limit exceeded" @Failure 500 {object} ErrorResponse "Internal server error" @Router /api/v1/pastes/{id} [patch]

type HealthCheckOutput

type HealthCheckOutput struct {
	S string `json:"status"`
	I struct {
		E string `json:"environment"`
		V string `json:"version"`
	} `json:"system_info"`
}

Jump to

Keyboard shortcuts

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