Documentation ¶
Index ¶
- func FileExists(filePath string) bool
- func GetUserRealIP(r *http.Request) string
- func IsIPValidAndPublic(ipAddr string) bool
- func IsPrivateIP(ip net.IP) bool
- type Config
- type Handler
- func (h *Handler) ApiDeleteAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiDeleteBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiDeleteViaExtension(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiGetAccounts(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiGetBookmarks(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiGetTags(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiInsertAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiInsertViaExtension(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiLogout(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiRenameTag(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiUpdateAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiUpdateBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ApiUpdateBookmarkTags(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) GetSessionID(r *http.Request) string
- func (h *Handler) PrepareSessionCache()
- func (h *Handler) PrepareTemplates() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶ added in v1.6.0
func GetUserRealIP ¶ added in v1.5.5
GetUserRealIP Get User Real IP from headers of request `r`
- First, determine whether the remote addr of request is a private address. If it is a public network address, return it directly;
- Otherwise, get and check the real IP from X-REAL-IP and X-Forwarded-For headers in turn. if the header value contains multiple IP addresses separated by commas, that is, the request may pass through multiple reverse proxies, we just keep the first one, which imply it is the user connecting IP. then we check the value is a valid public IP address using the `IsIPValidAndPublic` function. If it is, the function returns the value as the client's real IP address.
- Finally, If the above headers do not exist or are invalid, the remote addr is returned as is.
func IsIPValidAndPublic ¶ added in v1.5.5
IsIPValidAndPublic is a helper function check if an IP address is valid and public.
func IsPrivateIP ¶ added in v1.5.5
IsPrivateIP check IPv4 or IPv6 address according to the length of byte array
Types ¶
type Config ¶ added in v1.5.1
type Config struct { DB database.DB DataDir string ServerAddress string ServerPort int RootPath string Log bool }
Config is parameter that used for starting web server
type Handler ¶ added in v1.6.0
type Handler struct { DB database.DB DataDir string RootPath string UserCache *cch.Cache SessionCache *cch.Cache ArchiveCache *cch.Cache Log bool // contains filtered or unexported fields }
Handler is Handler for serving the web interface.
func GetLegacyHandler ¶ added in v1.6.0
func GetLegacyHandler(cfg Config, dependencies *dependencies.Dependencies) *Handler
func (*Handler) ApiDeleteAccount ¶ added in v1.6.0
func (h *Handler) ApiDeleteAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiDeleteAccount is handler for DELETE /api/accounts
func (*Handler) ApiDeleteBookmark ¶ added in v1.6.0
func (h *Handler) ApiDeleteBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiDeleteBookmarks is handler for DELETE /api/bookmark
func (*Handler) ApiDeleteViaExtension ¶ added in v1.6.0
func (h *Handler) ApiDeleteViaExtension(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiDeleteViaExtension is handler for DELETE /api/bookmark/ext
func (*Handler) ApiGetAccounts ¶ added in v1.6.0
func (h *Handler) ApiGetAccounts(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiGetAccounts is handler for GET /api/accounts
func (*Handler) ApiGetBookmarks ¶ added in v1.6.0
func (h *Handler) ApiGetBookmarks(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiGetBookmarks is handler for GET /api/bookmarks
func (*Handler) ApiGetTags ¶ added in v1.6.0
func (h *Handler) ApiGetTags(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiGetTags is handler for GET /api/tags
func (*Handler) ApiInsertAccount ¶ added in v1.6.0
func (h *Handler) ApiInsertAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiInsertAccount is handler for POST /api/accounts
func (*Handler) ApiInsertBookmark ¶ added in v1.6.0
func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiInsertBookmark is handler for POST /api/bookmark
func (*Handler) ApiInsertViaExtension ¶ added in v1.6.0
func (h *Handler) ApiInsertViaExtension(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiInsertViaExtension is handler for POST /api/bookmarks/ext
func (*Handler) ApiLogout ¶ added in v1.6.0
func (h *Handler) ApiLogout(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiLogout is handler for POST /api/logout
func (*Handler) ApiRenameTag ¶ added in v1.6.0
func (h *Handler) ApiRenameTag(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiRenameTag is handler for PUT /api/tag
func (*Handler) ApiUpdateAccount ¶ added in v1.6.0
func (h *Handler) ApiUpdateAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiUpdateAccount is handler for PUT /api/accounts
func (*Handler) ApiUpdateBookmark ¶ added in v1.6.0
func (h *Handler) ApiUpdateBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiUpdateBookmark is handler for PUT /api/bookmarks
func (*Handler) ApiUpdateBookmarkTags ¶ added in v1.6.0
func (h *Handler) ApiUpdateBookmarkTags(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiUpdateBookmarkTags is handler for PUT /api/bookmarks/tags
func (*Handler) GetSessionID ¶ added in v1.6.0
func (*Handler) PrepareSessionCache ¶ added in v1.6.0
func (h *Handler) PrepareSessionCache()