handlers

package
v0.0.0-...-b6e0fdc Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleSendJSON

func HandleSendJSON(w http.ResponseWriter, status int, v any, rc *types.RequestCtx) error

Handles the sending of JSON responses to the client. it's responsible for setting the response headers and status code as well as any data that needs to be sent. data should be serialized before being passed to this function.

func HandleUnsupportedMethod

func HandleUnsupportedMethod(w http.ResponseWriter, r *http.Request) error

fallthrough handler for unsupported methods

func ResolveResponse

func ResolveResponse(rc *types.RequestCtx) error

finalizes the response and sends it to the client

func ResolveResponseErr

func ResolveResponseErr(rc *types.RequestCtx, err types.APIError) error

resolves an error response and sends it to the client

func WrapFn

wraps a handle func with a request context and error handling populates request context with request details such as the account making the request (if any)

Types

type AccountHandler

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

func InitAccountHandlers

func InitAccountHandlers(rh *types.RoutingHandler) *AccountHandler

func (*AccountHandler) RegisterAccountLogin

func (ah *AccountHandler) RegisterAccountLogin(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/account/login

/**********************************************************************************************

func (*AccountHandler) RegisterAccountLogout

func (ah *AccountHandler) RegisterAccountLogout(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/account/logout

/**********************************************************************************************

func (*AccountHandler) RegisterAccountPosts

func (ah *AccountHandler) RegisterAccountPosts(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/account/posts

/**********************************************************************************************

func (*AccountHandler) RegisterAccountRegister

func (ah *AccountHandler) RegisterAccountRegister(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/account/register

/**********************************************************************************************

func (*AccountHandler) RegisterAccountRoot

func (ah *AccountHandler) RegisterAccountRoot(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/account

/**********************************************************************************************

type ArticleHandler

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

func InitArticleHandler

func InitArticleHandler(rh *types.RoutingHandler) *ArticleHandler

func (*ArticleHandler) RegisterArticleRoot

func (ah *ArticleHandler) RegisterArticleRoot(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/articles

/**********************************************************************************************

func (*ArticleHandler) RegisterArticleSlug

func (ah *ArticleHandler) RegisterArticleSlug(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/articles/{slug}

/**********************************************************************************************

type AssetHandler

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

func InitAssetHandler

func InitAssetHandler(rh *types.RoutingHandler) *AssetHandler

func (*AssetHandler) RegisterAssetRoot

func (ah *AssetHandler) RegisterAssetRoot(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/assets

/**********************************************************************************************

type BoardHandler

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

func InitBoardHandler

func InitBoardHandler(rh *types.RoutingHandler) *BoardHandler

func (*BoardHandler) RegisterBoardRoot

func (bh *BoardHandler) RegisterBoardRoot(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/boards

/**********************************************************************************************

func (*BoardHandler) RegisterBoardShort

func (bh *BoardHandler) RegisterBoardShort(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/boards/{short}

/**********************************************************************************************

type HandlerWrapperFunc

type HandlerWrapperFunc func(rc *types.RequestCtx) error

type InternalHandler

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

func InitInternalHandlers

func InitInternalHandlers(rh *types.RoutingHandler) *InternalHandler

func (*InternalHandler) HandleGetPost

func (ih *InternalHandler) HandleGetPost(rc *types.RequestCtx) error

METHOD: GET PATH: /api/internal/post/{thread_slug}/{post_number} retreives a post by first looking up the thread, then finding the post with that thread_id and post_number

func (*InternalHandler) HandleGetSession

func (ih *InternalHandler) HandleGetSession(rc *types.RequestCtx) error

METHOD: GET PATH: /api/internal/session/{session_id} retreives a session from it's id

func (*InternalHandler) HandleGetThread

func (ih *InternalHandler) HandleGetThread(rc *types.RequestCtx) error

METHOD: GET PATH: /api/internal/thread/{board_short}/{thread_slug}

type ThreadHandler

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

func InitThreadHandler

func InitThreadHandler(rh *types.RoutingHandler) *ThreadHandler

func (*ThreadHandler) RegisterThreadRoot

func (th *ThreadHandler) RegisterThreadRoot(rc *types.RequestCtx) error

*********************************************************************************************

ROOT path: host.com/api/threads/{slug}

/**********************************************************************************************

Jump to

Keyboard shortcuts

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