handler

package
v0.0.0-...-4018599 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiErrorNotAuth               ApiErrorCode = 10101
	ApiErrorAuthPwdError                       = 10102
	ApiErrorAuthIdentifieNotFound              = 10103 //name or email

	ApiErrorParamNeedId     = 10201
	ApiErrorParamIdNotFound = 10202
	ApiErrorParamIdFmtErr   = 10203
	ApiErrorParamErr        = 10203

	ApiErrorTokenSignErr  = 10301
	ApiErrorTokenParseErr = 10302
	ApiErrorTokenNotFound = 10303

	ApiErrorGoogleSearchQueryWordNotFound = 10401
	ApiErrorGoogleSearchErr               = 10402

	ApiErrorZmqMsgNotFound        = 10501
	ApiErrorZmqCanNotCreateSocket = 10502
	ApiErrorZmqRequestTimeout     = 10503
	ApiErrorZmqErr                = 10504

	ApiErrorTaskQueueRequestTimeout = 10601

	ApiErrorUnknow = 19901
)

error code define _ __ __

View Source
const (
	REQUEST_TIMEOUT = 2000 * time.Millisecond //  msecs, (> 1000!)
	REQUEST_RETRIES = 3                       //  Before we abandon
	SERVER_ENDPOINT = "inproc://zmq/msg/queue"
)

Variables

This section is empty.

Functions

func CreateCommentForPostIdHandler

func CreateCommentForPostIdHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func CreatePostHandler

func CreatePostHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func CreateUserHandler

func CreateUserHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func GetPostByPostIdHandler

func GetPostByPostIdHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func GetPostsByUserIdHandler

func GetPostsByUserIdHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func GetUserByUserIdHandler

func GetUserByUserIdHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func GetUsersHandler

func GetUsersHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func GoogleSearchHandler

func GoogleSearchHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, req *http.Request) (int, error)

func PostSigninHandler

func PostSigninHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func PubTaskHandler

func PubTaskHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func ReqRepTaskHandler

func ReqRepTaskHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

func ZMQWithTimeoutHandler

func ZMQWithTimeoutHandler(appCtx *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error)

Types

type ApiError

type ApiError struct {
	Code ApiErrorCode `json: "code"`
	Err  error        `json: "err"`
}

func (*ApiError) Error

func (err *ApiError) Error() string

type ApiErrorCode

type ApiErrorCode int

type ApiHandler

type ApiHandler struct {
	AppCtx  *appcontext.AppContext
	Handler func(*appcontext.AppContext, http.ResponseWriter, *http.Request) (int, error)
}

func (ApiHandler) ServeHTTP

func (ah ApiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ApiToken

type ApiToken struct {
	UserId string `json:"userId"`
	Token  string `json:"token"`
}

type Result

type Result struct {
	Title string `json:"title"`
	URL   string `json:"url"`
}

A Result contains the title and URL of a search result.

type Results

type Results []Result

////////////////// Do Google searches using the Google Web Search API. See https://developers.google.com/web-search/docs/ ////////////////// Results is an ordered list of search results.

Jump to

Keyboard shortcuts

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