Documentation ¶
Index ¶
- type AdminController
- func (admin *AdminController) AuthenticateAdmin(res http.ResponseWriter, req *http.Request)
- func (admin *AdminController) Login(res http.ResponseWriter, req *http.Request)
- func (admin *AdminController) Logout(res http.ResponseWriter, req *http.Request)
- func (admin *AdminController) RemoveSession(res http.ResponseWriter, req *http.Request)
- func (admin *AdminController) RemoveURL(res http.ResponseWriter, req *http.Request)
- func (admin *AdminController) RemoveUser(res http.ResponseWriter, req *http.Request)
- func (admin *AdminController) ViewSessions(res http.ResponseWriter, req *http.Request)
- func (admin *AdminController) ViewURLs(res http.ResponseWriter, req *http.Request)
- func (admin *AdminController) ViewUsers(res http.ResponseWriter, req *http.Request)
- type GoogleLogin
- type RequestDataManager
- type UIManager
- func (ui *UIManager) GetPageHandlerByName(pageName string) func(res http.ResponseWriter, req *http.Request)
- func (ui *UIManager) HandleTracking(res http.ResponseWriter, req *http.Request)
- func (ui *UIManager) HandleURLDataTracking(res http.ResponseWriter, req *http.Request)
- func (ui *UIManager) HandleUserInfo(res http.ResponseWriter, req *http.Request)
- type URLManager
- func (um *URLManager) GetURLData(url *models.URL) []*models.URLData
- func (um *URLManager) HandleCreateShortURL(res http.ResponseWriter, req *http.Request)
- func (um *URLManager) HandleGetFullURL(res http.ResponseWriter, req *http.Request)
- func (um *URLManager) HandleRemoveURL(res http.ResponseWriter, req *http.Request)
- func (um *URLManager) HandleRickRoll(res http.ResponseWriter, req *http.Request)
- func (um *URLManager) TrackURLData(req *http.Request)
- type UserManager
- func (um *UserManager) GTFO(res http.ResponseWriter, req *http.Request)
- func (um *UserManager) GetURLsOfUser(user *models.User) []*models.URL
- func (um *UserManager) GetUserFromRequest(req *http.Request) *models.User
- func (um *UserManager) Logout(res http.ResponseWriter, req *http.Request)
- func (um *UserManager) SetToken(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminController ¶
type AdminController struct {
// contains filtered or unexported fields
}
AdminController represents admin functionalities
func NewAdminController ¶
func NewAdminController(dbManager models.Database, conf *config.Config, uniqueID *utils.UniqueID, uiManager *UIManager) *AdminController
NewAdminController returns a new AdminController instance
func (*AdminController) AuthenticateAdmin ¶
func (admin *AdminController) AuthenticateAdmin(res http.ResponseWriter, req *http.Request)
AuthenticateAdmin checks admin credentials POST /admin/auth/
func (*AdminController) Login ¶
func (admin *AdminController) Login(res http.ResponseWriter, req *http.Request)
Login logs in the admin user :) GET /admin/
func (*AdminController) Logout ¶
func (admin *AdminController) Logout(res http.ResponseWriter, req *http.Request)
Logout deletes the current admin session GET /admin/logout/
func (*AdminController) RemoveSession ¶
func (admin *AdminController) RemoveSession(res http.ResponseWriter, req *http.Request)
RemoveSession deletes a session from the database DELETE /admin/sessions/remove/?session=sessionToken
func (*AdminController) RemoveURL ¶
func (admin *AdminController) RemoveURL(res http.ResponseWriter, req *http.Request)
RemoveURL deletes a given URL from the database DELETE /admin/urls/remove/?url=shortURL
func (*AdminController) RemoveUser ¶
func (admin *AdminController) RemoveUser(res http.ResponseWriter, req *http.Request)
RemoveUser deletes a given user from the database DELETE /admin/users/remove/?user=someUser
func (*AdminController) ViewSessions ¶
func (admin *AdminController) ViewSessions(res http.ResponseWriter, req *http.Request)
ViewSessions lists all active sessions in the database GET /admin/sessions/
func (*AdminController) ViewURLs ¶
func (admin *AdminController) ViewURLs(res http.ResponseWriter, req *http.Request)
ViewURLs lists all short URLs in the database GET /admin/urls/
func (*AdminController) ViewUsers ¶
func (admin *AdminController) ViewUsers(res http.ResponseWriter, req *http.Request)
ViewUsers lists all users in the database GET /admin/users/
type GoogleLogin ¶
type GoogleLogin struct {
// contains filtered or unexported fields
}
GoogleLogin holds google login handlers
func NewGoogleLogin ¶
func NewGoogleLogin(randomizer *useless.RandASCII, config *config.Config, requestDataManager *RequestDataManager, dbManager models.Database) *GoogleLogin
NewGoogleLogin returns a new GoogleLogin instance
func (*GoogleLogin) HandleCallback ¶
func (g *GoogleLogin) HandleCallback(w http.ResponseWriter, r *http.Request)
HandleCallback is called when authenticating with google
func (*GoogleLogin) LoginWithGoogle ¶
func (g *GoogleLogin) LoginWithGoogle(w http.ResponseWriter, r *http.Request)
LoginWithGoogle handles login using google authentication
type RequestDataManager ¶
type RequestDataManager struct {
// contains filtered or unexported fields
}
RequestDataManager manages data from requests
func NewRequestDataManager ¶
func NewRequestDataManager(config *config.Config, dbManager models.Database) *RequestDataManager
NewRequestDataManager returns a new RequestDataManager instance
func (*RequestDataManager) GetIP ¶
func (reqData *RequestDataManager) GetIP(req *http.Request) string
GetIP gets a requests IP address by reading off the forwarded-for header (for proxies) and falls back to use the remote address.
func (*RequestDataManager) GetURLDataFromRequestData ¶
func (reqData *RequestDataManager) GetURLDataFromRequestData(req *http.Request) *models.URLData
GetURLDataFromRequestData returns a URLData instance with the needed data
type UIManager ¶
type UIManager struct {
// contains filtered or unexported fields
}
UIManager holds the UI handlers
func NewUIManager ¶
func NewUIManager(userManager *UserManager, urlManager *URLManager, templates *template.Template, config *config.Config) *UIManager
NewUIManager returns a new UIManager instance
func (*UIManager) GetPageHandlerByName ¶
func (ui *UIManager) GetPageHandlerByName(pageName string) func(res http.ResponseWriter, req *http.Request)
GetPageHandlerByName returns a handler function depending on page name
func (*UIManager) HandleTracking ¶
func (ui *UIManager) HandleTracking(res http.ResponseWriter, req *http.Request)
HandleTracking renders the URLs tracking page of a specific user
func (*UIManager) HandleURLDataTracking ¶
func (ui *UIManager) HandleURLDataTracking(res http.ResponseWriter, req *http.Request)
HandleURLDataTracking renders the URLs tracking page of a specific user
func (*UIManager) HandleUserInfo ¶
func (ui *UIManager) HandleUserInfo(res http.ResponseWriter, req *http.Request)
HandleUserInfo renders the user info page
type URLManager ¶
type URLManager struct {
// contains filtered or unexported fields
}
URLManager holds URL operations handlers
func NewURLManager ¶
func NewURLManager(urlValidator *utils.URLValidator, requestDataManager *RequestDataManager, userManager *UserManager, randomStringGenerator *useless.RandASCII, db models.Database) *URLManager
NewURLManager returns a new URLManager instance
func (*URLManager) GetURLData ¶
func (um *URLManager) GetURLData(url *models.URL) []*models.URLData
GetURLData returns a slice of URLData of the given URL
func (*URLManager) HandleCreateShortURL ¶
func (um *URLManager) HandleCreateShortURL(res http.ResponseWriter, req *http.Request)
HandleCreateShortURL creates a short url for the given url GET /shorten/?url=http://someurl.com
func (*URLManager) HandleGetFullURL ¶
func (um *URLManager) HandleGetFullURL(res http.ResponseWriter, req *http.Request)
HandleGetFullURL retrieves the original url of the given short url GET /{[A-Z;0-9;a-z]{4,5}}
func (*URLManager) HandleRemoveURL ¶
func (um *URLManager) HandleRemoveURL(res http.ResponseWriter, req *http.Request)
HandleRemoveURL removes the given url from the database DELETE /remove/?short=shortHandler
func (*URLManager) HandleRickRoll ¶
func (um *URLManager) HandleRickRoll(res http.ResponseWriter, req *http.Request)
HandleRickRoll redirects to Rick Astley's - Never Gonna Give You Up YT Video, perfect RickRolling :) GET /no_url/
func (*URLManager) TrackURLData ¶
func (um *URLManager) TrackURLData(req *http.Request)
TrackURLData stores short URL data if the short URL is assigned to a specific user
type UserManager ¶
type UserManager struct {
// contains filtered or unexported fields
}
UserManager holds different user operations
func NewUserManager ¶
func NewUserManager(dbManager models.Database, requestDataManager *RequestDataManager) *UserManager
NewUserManager returns a new UserManager instance
func (*UserManager) GTFO ¶
func (um *UserManager) GTFO(res http.ResponseWriter, req *http.Request)
GTFO magically logs out!
func (*UserManager) GetURLsOfUser ¶
func (um *UserManager) GetURLsOfUser(user *models.User) []*models.URL
GetURLsOfUser returns a slice with all URLs of a certain user from the database
func (*UserManager) GetUserFromRequest ¶
func (um *UserManager) GetUserFromRequest(req *http.Request) *models.User
GetUserFromRequest returns a user from the database using the caller ip it was called from!
func (*UserManager) Logout ¶
func (um *UserManager) Logout(res http.ResponseWriter, req *http.Request)
Logout deletes the current session of a user
func (*UserManager) SetToken ¶
func (um *UserManager) SetToken(w http.ResponseWriter, r *http.Request)
SetToken sets token as cookie in the page