http

package
v0.0.0-...-af438c1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PageIDKey refers to the context key that stores the next page id
	PageIDKey string = "page_id"
)

Variables

This section is empty.

Functions

func ListArticles

func ListArticles(w http.ResponseWriter, r *http.Request)

func LogWarningsWithRequestInfo

func LogWarningsWithRequestInfo(r *http.Request, message interface{})

Types

type Handler

type Handler struct {
	// service and router
	Router             *chi.Mux
	UserService        *user.Service
	QuestionService    *question.Service
	TopWordsService    topwords.ITopTenWords
	CollectiveService  *collective.Service
	FeedService        *feed.Service
	VerificationServie *verification.Service
	EventServie        *events.Service
}

func NewHandler

func NewHandler(userService *user.Service,
	questionService *question.Service,
	topwordsservice topwords.ITopTenWords,
	collectiveService *collective.Service,
	feedservice *feed.Service,
	verificationService *verification.Service,
	eventservice *events.Service,
) *Handler

NewHandler - construcutre to create and return a pointer to a handler

func (*Handler) ApprovePost

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

@Summary approve post @Description approve post @Accept json @Produce json @Param collective path string true "collective slug" @Param post path string true "post slug" @Success 200 {object} collective.Post @Router /collectives/{collective}/{post}/approve [POST] @Security JWT @Tags Collectives

func (*Handler) CreateAdminUser

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

func (*Handler) CreateCollective

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

@Summary Create a new CreateCollective @Description creating a new collective @in header @Accept json @Produce json @Param payload body collective.Collective true "payload" @Success 200 {object} collective.Collective @Router /collective/create [POST] @Security JWT @Tags Collective

func (*Handler) CreateNewEvent

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

func (*Handler) CreatePost

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

@Summary Create a new Question @Description create a new question @in header @Accept json @Produce json @Param payload body question.QuestionCreateRequest true "payload" @Success 200 {object} question.Question @Router /question/create [POST] @Security JWT @Tags Question

func (*Handler) CreateUser

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

@Summary Register @Description register a new user @Accept json @Produce json @Param payload body user.CreateUserRequest true "payload" @Success 200 {object} user.User @Router /user/join [POST] @Tags User

func (*Handler) FetchCollectives

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

@Summary Get all Collectives @Description get all collectives @in header @Accept json @Produce json @Success 200 {array} collective.Collective @Router /collectives [GET] @Tags Collective

func (*Handler) FindPostsByTag

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

@Summary get posts by tags @Description find posts by using tag @Accept json @Produce json @Param tag path string true "Tag Name" @Success 200 {array} question.Question @Router /view/questions/{tag} [GET] @Tags Question

func (*Handler) GetAllPosts

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

@Summary fetch all posts @Description Get all the posts @in header @Accept json @Produce json @Param next_post query int true "Next Post" @Success 200 {array} question.Question @Router /view/questions [GET] @Tags Question

func (*Handler) GetAllUsers

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

@TODO add pagiation

func (*Handler) GetCollectiveBySlug

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

@Summary get collective by slug @Description get infromation about a collecting using slug @in header @Accept json @Produce json @Param collective path string true "collective slug" @Success 200 {object} collective.Collective @Router /collectives/{collective} [GET] @Tags Collectives

func (*Handler) GetEngagementFeed

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

@Router /user/feed [GET] @Tags Feed

func (*Handler) GetNofications

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

@Summary get notifications @Description Get nofications for the current user @Accept json @Produce json @Success 200 {array} user.Nofication @Router /user/nofications [GET] @Security JWT @Tags User

func (*Handler) GetPostbySlug

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

@Summary view post @Description view post details @Accept json @Produce json @Param post path string true "post slug" @Success 200 {object} collective.Post @Router /post/{post} [GET] @Tags Collectives

func (*Handler) GetQuestionBasedonSlug

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

func (Handler) GetUserByID

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

func (*Handler) GeteventsBySlug

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

func (*Handler) GetmyTobeApprovePosts

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

func (*Handler) HighPrivilagesMiddlewhare

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

func (*Handler) JWTMiddlewhare

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

func (*Handler) Joincollective

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

func (*Handler) ListArticles

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

=========== find posts pagination test =========================

func (*Handler) LoggedinUser

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

func (*Handler) Login

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

@Summary Authenticate User @Description login as a existing user @Accept json @Produce json @Param payload body types.Login true "payload" @Success 200 {object} types.AuthRequest @Router /user/login [POST] @Tags Authentication

func (*Handler) Pagination

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

Pagination middleware is used to extract the next page id from the url query

func (*Handler) RefreshToken

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

@Summary Refresh Tokens @Description refresh users token based on a given refresh token @Accept json @Produce json @Param payload body RefreshReq true "payload" @Success 200 {object} RefreshResponse @Router /user/refresh [POST] @Tags Authentication

func (*Handler) RequestVerification

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

func (*Handler) SearchPost

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

@Summary search for posts @Description Search Posts based on a keyword @Accept json @Produce json @Param q query string true "Search Query" @Success 200 {array} question.Question @Router /view/search [GET] @Tags Question

func (*Handler) SetupRotues

func (h *Handler) SetupRotues()

func (*Handler) TestRoute

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

func (*Handler) UpvotePost

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

@Summary Upvote a question @Description upvote a question @Accept json @Produce json @Router /question/upvote [PATCH] @Tags Question @Param payload body VoteStruct true "payload" @Success 200 {array} question.Question @Security JWT

func (*Handler) UserApplyforMod

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

func (*Handler) VerifyEmail

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

func (*Handler) ViewUnaprovedPosts

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

@Summary view unaproved posts @Description list all unaproved posts in a collective @Accept json @Produce json @Param collective path string true "collective slug" @Success 200 {object} collective.Post @Router /collectives/{collective}/unaproved [GET] @Security JWT @Tags Collectives

func (*Handler) ViewallEvents

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

func (*Handler) WriteAnswer

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

@Summary Write Answer @Description Answer to a question @Accept json @Produce json @Param payload body question.AnswerRequest true "payload" @Param qid path uint true "Question ID" @Success 200 {array} question.Answer @Router /question/{qid}/answer/create [POST] @Security JWT @Tags Answer

func (*Handler) WritePostinCollective

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

@Summary write a post @Description create a post in collective @in header @Accept json @Produce json @Param collective path string true "collective slug" @Success 200 {object} collective.Post @Router /collectives/{collective}/post/write [POST] @Tags Collectives

type RefreshReq

type RefreshReq struct {
	Token string `json:"refresh_token"`
}

type RefreshResponse

type RefreshResponse struct {
	Auth       string `json:"auth"`
	Authexp    int64  `json:"auth_expire"`
	Refresh    string `json:"refresh"`
	Refreshexp int64  `json:"refresh_expire"`
	UserRole   int    `json:"user_type"`
}

type SuccessResultUpvote

type SuccessResultUpvote struct {
	Success bool `json:"success"`
}

type VoteStruct

type VoteStruct struct {
	ID uint `json:"id"`
}

Jump to

Keyboard shortcuts

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