Documentation ¶
Index ¶
- Constants
- type API
- func (api *API) AccessLink(w http.ResponseWriter, r *http.Request)
- func (api *API) AccessSetting(w http.ResponseWriter, r *http.Request)
- func (api *API) AccessTag(w http.ResponseWriter, r *http.Request)
- func (api *API) AddHandler(router *mux.Router)
- func (api *API) AddTag(w http.ResponseWriter, r *http.Request)
- func (api *API) AuthMiddleware(next http.Handler) http.Handler
- func (api *API) BrowseLinks(w http.ResponseWriter, r *http.Request)
- func (api *API) DeleteLink(w http.ResponseWriter, r *http.Request)
- func (api *API) DeleteSetting(w http.ResponseWriter, r *http.Request)
- func (api *API) DeleteTag(w http.ResponseWriter, r *http.Request)
- func (api *API) EditLink(w http.ResponseWriter, r *http.Request)
- func (api *API) EditTag(w http.ResponseWriter, r *http.Request)
- func (api *API) GetLink(w http.ResponseWriter, r *http.Request)
- func (api *API) GetLinkFromContext(r *http.Request) *db.Link
- func (api *API) GetSetting(w http.ResponseWriter, r *http.Request)
- func (api *API) GetSettings(w http.ResponseWriter, r *http.Request)
- func (api *API) GetTag(w http.ResponseWriter, r *http.Request)
- func (api *API) GetTagFromContext(r *http.Request) *db.Tag
- func (api *API) GetUser(r *http.Request) *db.User
- func (api *API) GetUserFromContext(r *http.Request) *db.User
- func (api *API) ImportLinks(w http.ResponseWriter, r *http.Request)
- func (api *API) LinkMiddleware(next http.Handler) http.Handler
- func (api *API) ListTags(w http.ResponseWriter, r *http.Request)
- func (api *API) Login(w http.ResponseWriter, r *http.Request)
- func (api *API) Logout(w http.ResponseWriter, r *http.Request)
- func (api *API) Register(w http.ResponseWriter, r *http.Request)
- func (api *API) SaveLink(w http.ResponseWriter, r *http.Request)
- func (api *API) StartElasticQueue()
- func (api *API) Stop()
- func (api *API) TagMiddleware(next http.Handler) http.Handler
- func (api *API) UpdateAuth(w http.ResponseWriter, r *http.Request)
- func (api *API) UpdateSetting(w http.ResponseWriter, r *http.Request)
- func (api *API) ValidateLink(w http.ResponseWriter, link apiLink) bool
- func (api *API) ValidateTag(w http.ResponseWriter, tag *db.Tag) bool
Constants ¶
const ElasticIndex = "lindeb"
const ElasticType = "link"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
API contains objects needed by the API handlers to function.
func (*API) AccessLink ¶
func (api *API) AccessLink(w http.ResponseWriter, r *http.Request)
AccessLink is a method proxy for the handlers of /api/link/<id>
func (*API) AccessSetting ¶ added in v0.3.0
func (api *API) AccessSetting(w http.ResponseWriter, r *http.Request)
func (*API) AccessTag ¶
func (api *API) AccessTag(w http.ResponseWriter, r *http.Request)
AccessTag is a method proxy for the handlers of /api/tag/<id>
func (*API) AddHandler ¶
AddHandler registers all the API paths.
func (*API) AuthMiddleware ¶
AuthMiddleware provides a HTTP handler middleware that loads the user data of the sender to the request context.
If the user is not logged in, HTTP Unauthorized is returned and the next handler is not called.
func (*API) BrowseLinks ¶
func (api *API) BrowseLinks(w http.ResponseWriter, r *http.Request)
BrowseLinks is the handler for GET /api/links
func (*API) DeleteLink ¶
func (api *API) DeleteLink(w http.ResponseWriter, r *http.Request)
DeleteLink is the handler for DELETE /api/link/<id>
func (*API) DeleteSetting ¶ added in v0.3.0
func (api *API) DeleteSetting(w http.ResponseWriter, r *http.Request)
func (*API) EditLink ¶
func (api *API) EditLink(w http.ResponseWriter, r *http.Request)
EditLink is the handler for PUT /api/link/<id>
func (*API) EditTag ¶
func (api *API) EditTag(w http.ResponseWriter, r *http.Request)
EditTag is the handler for PUT /api/link/<id>
func (*API) GetLink ¶
func (api *API) GetLink(w http.ResponseWriter, r *http.Request)
GetLink is the handler for GET /api/link/<id>
func (*API) GetLinkFromContext ¶
GetLinkFromContext gets the database link object from the context of the given request.
Calling this function with a request that did not go through the link getter middleware is strictly forbidden and will cause a panic.
func (*API) GetSetting ¶ added in v0.3.0
func (api *API) GetSetting(w http.ResponseWriter, r *http.Request)
func (*API) GetSettings ¶ added in v0.3.0
func (api *API) GetSettings(w http.ResponseWriter, r *http.Request)
func (*API) GetTag ¶
func (api *API) GetTag(w http.ResponseWriter, r *http.Request)
GetTag is the handler for GET /api/tag/<id>
func (*API) GetTagFromContext ¶
GetTagFromContext gets the database tag object from the context of the given request.
Calling this function with a request that did not go through the tag getter middleware is strictly forbidden and will cause a panic.
func (*API) GetUser ¶
GetUser gets the apiUser who sent the request, or nil if the sender is not logged in.
func (*API) GetUserFromContext ¶
GetUserFromContext gets the database user object from the context of the given request.
Calling this function with a request that did not go through the auth check middleware is strictly forbidden and will cause a panic.
func (*API) ImportLinks ¶ added in v0.3.0
func (api *API) ImportLinks(w http.ResponseWriter, r *http.Request)
func (*API) LinkMiddleware ¶
LinkMiddleware provides a HTTP handler middleware that loads the data of the link with the requested ID to the request context.
You must call the authentication middleware BEFORE this function, as this depends on the user being logged in.
If the request path doesn't contain the id field, HTTP Bad Request is returned. If the requested link does not exist or is not owned by the current user, HTTP Not Found is returned. In both error cases, the next handler is not called.
func (*API) Login ¶
func (api *API) Login(w http.ResponseWriter, r *http.Request)
Login checks the provided password and generates a new authentication token that is sent back to the apiUser.
func (*API) Logout ¶
func (api *API) Logout(w http.ResponseWriter, r *http.Request)
Logout invalidates the authentication token sent with the request.
func (*API) Register ¶
func (api *API) Register(w http.ResponseWriter, r *http.Request)
Register creates a new apiUser and logs in.
func (*API) SaveLink ¶
func (api *API) SaveLink(w http.ResponseWriter, r *http.Request)
SaveLink is a handler for POST /api/link/save
func (*API) StartElasticQueue ¶ added in v0.3.0
func (api *API) StartElasticQueue()
func (*API) TagMiddleware ¶
TagMiddleware provides a HTTP handler middleware that loads the data of the tag with the requested ID to the request context.
You must call the authentication middleware BEFORE this function, as this depends on the user being logged in.
If the request path doesn't contain the id field, HTTP Bad Request is returned. If the requested tag does not exist or is not owned by the current user, HTTP Not Found is returned. In both error cases, the next handler is not called.
func (*API) UpdateAuth ¶ added in v0.2.0
func (api *API) UpdateAuth(w http.ResponseWriter, r *http.Request)
func (*API) UpdateSetting ¶ added in v0.3.0
func (api *API) UpdateSetting(w http.ResponseWriter, r *http.Request)
func (*API) ValidateLink ¶ added in v1.0.0
func (api *API) ValidateLink(w http.ResponseWriter, link apiLink) bool