handlers

package
v0.0.0-...-f8ea5e8 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// MyBad alias for http.StatusInternalServerError
	MyBad = http.StatusInternalServerError

	// YourBad alias for http.StatusBadRequest
	YourBad = http.StatusBadRequest

	// OK alias for OK
	OK = http.StatusOK

	// NoInfo empty error for HTTPError.Info
	NoInfo = errors.New("-")

	// ErrInvalidValues error for invalid values in request
	ErrInvalidValues = e(YourBad, errors.New("invalid values"), NoInfo)
)

Functions

func AddFeedBack

func AddFeedBack(ctx echo.Context) error

AddFeedBack godoc @Summary Feedback messages @Produce json @Param data body contracts.AddFeedBackReq true "Feedback" @Success 200 {object} models.FeedBack @Router /feedback [put]

func AddOAuthService

func AddOAuthService(ctx echo.Context) error

AddOAuthService godoc @Summary Add oauth service account to user @Produce json @Param data body contracts.AddOAuthServiceReq true "Register id" @Security JWTAuth @Router /me/oauth-services [put]

func AdminDeleteUser

func AdminDeleteUser(ctx echo.Context) error

AdminDeleteUser godoc @Summary Delete user by id @Produce json @Param id path int true "User id" @Security JWTAuth @Router /admin/users/{id}/ [delete]

func AdminEditUser

func AdminEditUser(ctx echo.Context) error

AdminEditUser godoc @Summary Edit user @Produce json @Param id path int true "User id" @Param data body contracts.AdminEditUserReq true "Info" @Security JWTAuth @Router /admin/users/{id}/ [put]

func AdminGetUsers

func AdminGetUsers(ctx echo.Context) error

AdminGetUsers godoc @Summary Users @Produce json @Param page path int false "Users list page" @Success 200 {array} models.User @Security JWTAuth @Router /admin/users/{page} [get]

func AuthMiddleware

func AuthMiddleware(h echo.HandlerFunc) echo.HandlerFunc

func DeleteFeedBack

func DeleteFeedBack(ctx echo.Context) error

DeleteFeedBack godoc @Summary Feedback messages @Produce json @Param feedback path int true "Feedback id" @Security JWTAuth @Router /admin/feedback/{feedback}/ [delete]

func DeleteOAuthService

func DeleteOAuthService(ctx echo.Context) error

DeleteOAuthService godoc @Summary Delete oauth service account from user @Produce json @Param oauthName path string true "OAuth service name" @Param inServiceId path string true "User in OAuth service id" @Security JWTAuth @Router /me/oauth-services/{oauthName}/{inServiceId} [delete]

func DeleteUser

func DeleteUser(ctx echo.Context) error

DeleteUser godoc @Summary Delete current user account @Produce json @Security JWTAuth @Router /me/ [delete]

func EditUser

func EditUser(ctx echo.Context) error

EditUser godoc @Summary Edit user name/email/picture @Produce json @Param data body contracts.EditUserReq true "New user information" @Success 200 {object} models.User @Security JWTAuth @Router /me/ [put]

func EditUserPassword

func EditUserPassword(ctx echo.Context) error

EditUserPassword godoc @Summary Edit user password @Produce json @Param data body contracts.EditUserPasswordReq true "New password" @Success 200 {object} models.User @Security JWTAuth @Router /me/password [put]

func EditUserPicture

func EditUserPicture(ctx echo.Context) error

EditUserPicture godoc @Summary Edit user picture by file @Produce json @Param picture formData []byte true "Picture file" @Security JWTAuth @Router /me/picture [put]

func FeedBack

func FeedBack(ctx echo.Context) error

AllFeedBack godoc @Summary Feedback messages @Produce json @Param page path int false "Feedback list page" @Success 200 {array} models.FeedBack @Security JWTAuth @Router /admin/feedback/{page} [get]

func InitControllers

func InitControllers(inDB *sqlx.DB, inConfig *helpers.Config)

InitControllers update controllers global variables

func IsAdmin

func IsAdmin(next echo.HandlerFunc) echo.HandlerFunc

IsAdmin middleware for admins-only pages

func Login

func Login(ctx echo.Context) error

Login godoc @Summary Login @Description Login to an account @Accept json @Produce json @Param data body contracts.LoginReq true "User information" @Success 200 {object} contracts.LoginRes @Router /auth/login [post]

func Main

func Main(ctx echo.Context) error

Main godoc @Summary main example @Description main page @Accept json @Produce json @Success 200 {string} string "Hello, World!" @Router / [get]

func Me

func Me(ctx echo.Context) error

Me godoc @Summary Information about current user @Produce json @Success 200 {object} models.User @Security JWTAuth @Router /me/ [get]

func NewHTTPError

func NewHTTPError(code int, public, info error) error
func OAuthLinks(ctx echo.Context) error

OAuthLinks godoc @Summary Return links for oauth login @Accept json @Produce json @Success 200 {array} OAuthService @Router /oauth/register-info/{registerId} [get]

func OAuthRedirect

func OAuthRedirect(ctx echo.Context, oauth helpers.OAuthInfo) error

OAuthRedirect handler for POST /oauth/{service_name}/redirect

func OAuthRegister

func OAuthRegister(ctx echo.Context) error

OAuthRegister godoc @Summary Register account by oauth @Description Register a new account by oauth @Accept json @Produce json @Param data body contracts.OAuthRegisterReq true "Register information" @Success 200 {object} contracts.LoginRes @Router /oauth/register [post]

func OAuthRegisterInfo

func OAuthRegisterInfo(ctx echo.Context) error

OAuthRegisterInfo godoc @Summary Info about oauth registration @Accept json @Produce json @Param registerId path string true "Registration id" @Success 200 {object} models.OAuthRegister @Router /oauth/register-info/{registerId} [get]

func OAuthServices

func OAuthServices(ctx echo.Context) error

OAuthServices godoc @Summary Return all connected to account oauth services @Produce json @Success 200 {array} models.UserAccount @Security JWTAuth @Router /me/oauth-services [get]

func Refresh

func Refresh(ctx echo.Context) error

Refresh godoc @Summary Refresh JWT token @Accept json @Produce json @Param data body contracts.RefreshReq true "Refresh information" @Success 200 {object} contracts.LoginRes @Router /auth/refresh [post]

func Register

func Register(ctx echo.Context) error

Register godoc @Summary Register @Description Register a new account @Accept json @Produce json @Param data body contracts.RegisterReq true "User information" @Success 200 {object} models.PublicUser @Router /auth/register [post]

func User

func User(ctx echo.Context) error

User godoc @Summary Information about user @Produce json @Param id path int true "User id" @Success 200 {object} models.PublicUser @Router /users/{id} [get]

func UserByNick

func UserByNick(ctx echo.Context) error

UserByNick godoc @Summary Information about user @Produce json @Param nick path string true "User nick" @Success 200 {object} models.PublicUser @Router /usersByNick/{nick} [get]

func UserPicture

func UserPicture(ctx echo.Context) error

UserPicture godoc @Summary user picture @Accept json @Produce png @Param userId path string true "User id" @Router /user-picture/{userId} [get]

func VIPAdmin

func VIPAdmin(ctx echo.Context) error

VIPAdmin godoc @Summary VIP place for admins @Produce json @Success 200 {object} contracts.VIPRes @Security JWTAuth @Router /admin/vip [get]

Types

type HTTPError

type HTTPError struct {
	Code   int
	Public error // error message for user
	Info   error // error message for developers
}

func (HTTPError) Error

func (err HTTPError) Error() string

type OAuthService

type OAuthService struct {
	Name string `json:"name" example:"oauth service name`
	Link string `json:"link" example:"oauth service link`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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