Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidRegisterAuthToken = fmt.Errorf("invalid register auth token") ErrInvalidRequestBodyData = fmt.Errorf("invalid request body data") ErrCouldNotInsertToDatabase = fmt.Errorf("could not insert to database") ErrWrongLogin = fmt.Errorf("wrong password or email") ErrInvalidHash = fmt.Errorf("invalid hash") ErrImageNotFound = fmt.Errorf("image not found") ErrInvalidJSON = fmt.Errorf("invalid json body") )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { Router *chi.Mux // contains filtered or unexported fields }
API type represents the API HTTP server with JWT authentication capabilities.
func (*API) EnablePrometheusMetrics ¶
EnablePrometheusMetrics enables go-chi prometheus metrics under specified ID. If ID empty, the default "gochi_http" is used.
type HTTPContext ¶
type HTTPContext struct { Writer http.ResponseWriter Request *http.Request }
HTTPContext is the Context for an HTTP request.
func (*HTTPContext) Send ¶
func (h *HTTPContext) Send(msg []byte, httpStatusCode int) error
Send replies the request with the provided message.
func (*HTTPContext) URLParam ¶
func (h *HTTPContext) URLParam(key string) string
URLParam is a wrapper around go-chi to get a URL parameter (specified in the path pattern as {key})
type LoginResponse ¶
type Register ¶
type Register struct { UserEmail string `json:"email"` RegisterAuthToken string `json:"invitationToken"` UserProfile }
type Request ¶
type Request struct { Data []byte Path []string Context *HTTPContext UserID string }
Request represents an HTTP request to the API. It contains the request Body data, the URL path and the HTTP context. The context can be used for obtaining URL parameters and sending responses.
type Response ¶
type Response struct { Header ResponseHeader `json:"header"` Data any `json:"data,omitempty"` }
Response is the default response of the API
type ResponseHeader ¶
type ResponseHeader struct { Success bool `json:"success"` Message string `json:"message,omitempty"` ErrorCode int `json:"errorCode,omitempty"` }
ResponseHeader is the header of the response
type RouterHandlerFn ¶
RouterHandlerFn is the function signature for adding handlers to the HTTProuter.
type Tool ¶
type Tool struct { ID int64 `json:"id"` Title string `json:"title"` Description string `json:"description"` MayBeFree *bool `json:"mayBeFree"` AskWithFee *bool `json:"askWithFee"` Cost *uint64 `json:"cost"` Images [][]byte `json:"images"` TransportOptions []int `json:"transportOptions"` Category int `json:"category"` Location db.Location `json:"location"` EstimatedValue uint64 `json:"estimatedValue"` Height uint32 `json:"height"` Weight uint32 `json:"weight"` }
Tool is the type of the tool
type ToolSearch ¶
type ToolSearch struct { Term string `json:"term"` Categories []int `json:"categories"` Distance int `json:"distance"` MaxCost *uint64 `json:"maxCost"` MayBeFree *bool `json:"mayBeFree"` AvailableFrom int `json:"availableFrom"` }
ToolSearch is the type of the tool search