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 ¶
func GetUserRealIP ¶
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 ¶
IsIPValidAndPublic is a helper function check if an IP address is valid and public.
func IsPrivateIP ¶
IsPrivateIP check IPv4 or IPv6 address according to the length of byte array
Types ¶
type Config ¶
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 ¶
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 ¶
func GetLegacyHandler(cfg Config, dependencies *dependencies.Dependencies) *Handler
func (*Handler) ApiDeleteAccount ¶
func (h *Handler) ApiDeleteAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiDeleteAccount is handler for DELETE /api/accounts
func (*Handler) ApiDeleteBookmark ¶
func (h *Handler) ApiDeleteBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiDeleteBookmarks is handler for DELETE /api/bookmark
func (*Handler) ApiDeleteViaExtension ¶
func (h *Handler) ApiDeleteViaExtension(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiDeleteViaExtension is handler for DELETE /api/bookmark/ext
func (*Handler) ApiGetAccounts ¶
func (h *Handler) ApiGetAccounts(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiGetAccounts is handler for GET /api/accounts
func (*Handler) ApiGetBookmarks ¶
func (h *Handler) ApiGetBookmarks(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiGetBookmarks is handler for GET /api/bookmarks
func (*Handler) ApiGetTags ¶
func (h *Handler) ApiGetTags(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiGetTags is handler for GET /api/tags
func (*Handler) ApiInsertAccount ¶
func (h *Handler) ApiInsertAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiInsertAccount is handler for POST /api/accounts
func (*Handler) ApiInsertBookmark ¶
func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiInsertBookmark is handler for POST /api/bookmark
func (*Handler) ApiInsertViaExtension ¶
func (h *Handler) ApiInsertViaExtension(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiInsertViaExtension is handler for POST /api/bookmarks/ext
func (*Handler) ApiLogout ¶
func (h *Handler) ApiLogout(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiLogout is handler for POST /api/logout
func (*Handler) ApiRenameTag ¶
func (h *Handler) ApiRenameTag(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiRenameTag is handler for PUT /api/tag
func (*Handler) ApiUpdateAccount ¶
func (h *Handler) ApiUpdateAccount(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiUpdateAccount is handler for PUT /api/accounts
func (*Handler) ApiUpdateBookmark ¶
func (h *Handler) ApiUpdateBookmark(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiUpdateBookmark is handler for PUT /api/bookmarks
func (*Handler) ApiUpdateBookmarkTags ¶
func (h *Handler) ApiUpdateBookmarkTags(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ApiUpdateBookmarkTags is handler for PUT /api/bookmarks/tags
func (*Handler) PrepareSessionCache ¶
func (h *Handler) PrepareSessionCache()