Documentation ¶
Index ¶
- type ControllerFactory
- func (cf *ControllerFactory) GetFacebookController() Facebook
- func (cf *ControllerFactory) GetGoogleController() Google
- func (cf *ControllerFactory) GetGormDB() *gorm.DB
- func (cf *ControllerFactory) GetMailController() *MailController
- func (cf *ControllerFactory) GetMailService() services.MailService
- func (cf *ControllerFactory) GetMembershipController() *MembershipController
- func (cf *ControllerFactory) GetMgoSession() *mgo.Session
- func (cf *ControllerFactory) GetNewsController() *NewsController
- func (cf *ControllerFactory) GetOAuthController(oauthType string) (oauth *OAuth)
- type Facebook
- type Google
- type IndexPageQueryStruct
- type MailController
- type MembershipController
- func (mc *MembershipController) Activate(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) ActivateV2(c *gin.Context)
- func (mc *MembershipController) Close() error
- func (mc *MembershipController) CreateABookmarkOfAUser(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) CreateADonationOfAUser(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) CreateAPeriodicDonationOfAUser(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) DeleteABookmarkOfAUser(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) GetADonationOfAUser(c *gin.Context, donationType string) (int, gin.H, error)
- func (mc *MembershipController) GetBookmarksOfAUser(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) GetDonationsOfAUser(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) IsWebPushSubscribed(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) PatchADonationOfAUser(c *gin.Context, donationType string) (int, gin.H, error)
- func (mc *MembershipController) RenewJWT(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) SignIn(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) SignInV2(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) SubscribeWebPush(c *gin.Context) (int, gin.H, error)
- func (mc *MembershipController) TokenDispatch(c *gin.Context)
- func (mc *MembershipController) TokenInvalidate(c *gin.Context)
- type MenuItemsController
- type NewsController
- func (nc *NewsController) GetAPost(c *gin.Context)
- func (nc *NewsController) GetATopic(c *gin.Context)
- func (nc *NewsController) GetAuthors(c *gin.Context) (int, gin.H, error)
- func (nc *NewsController) GetCategoriesPosts(c *gin.Context)
- func (nc *NewsController) GetIndexPageContents(c *gin.Context)
- func (nc *NewsController) GetPosts(c *gin.Context)
- func (nc *NewsController) GetQueryParam(c *gin.Context) (mq models.MongoQuery, limit int, offset int, sort string, full bool)
- func (nc *NewsController) GetTopics(c *gin.Context)
- func (nc *NewsController) SearchAuthors(c *gin.Context)
- func (nc *NewsController) SearchPosts(c *gin.Context)
- type OAuth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControllerFactory ¶
type ControllerFactory struct {
// contains filtered or unexported fields
}
ControllerFactory generates controlloers by given persistent storage connection and mail service
func NewControllerFactory ¶
func NewControllerFactory(gormDB *gorm.DB, mgoSession *mgo.Session, mailSvc services.MailService) *ControllerFactory
NewControllerFactory generate *ControllerFactory struct
func (*ControllerFactory) GetFacebookController ¶
func (cf *ControllerFactory) GetFacebookController() Facebook
GetFacebookController returns Facebook struct
func (*ControllerFactory) GetGoogleController ¶
func (cf *ControllerFactory) GetGoogleController() Google
GetGoogleController returns Google struct
func (*ControllerFactory) GetGormDB ¶
func (cf *ControllerFactory) GetGormDB() *gorm.DB
GetMgoSession returns *gorm.DB it holds
func (*ControllerFactory) GetMailController ¶
func (cf *ControllerFactory) GetMailController() *MailController
GetMailController returns *MailController struct
func (*ControllerFactory) GetMailService ¶
func (cf *ControllerFactory) GetMailService() services.MailService
GetMailService returns MailService it holds
func (*ControllerFactory) GetMembershipController ¶
func (cf *ControllerFactory) GetMembershipController() *MembershipController
GetMembershipController returns *MembershipController struct
func (*ControllerFactory) GetMgoSession ¶
func (cf *ControllerFactory) GetMgoSession() *mgo.Session
GetMgoSession returns *mgo.Session it holds
func (*ControllerFactory) GetNewsController ¶
func (cf *ControllerFactory) GetNewsController() *NewsController
GetNewsController returns *NewsController struct
func (*ControllerFactory) GetOAuthController ¶
func (cf *ControllerFactory) GetOAuthController(oauthType string) (oauth *OAuth)
GetOAuthController returns OAuth struct
type Facebook ¶
type Facebook struct { Storage storage.MembershipStorage // contains filtered or unexported fields }
Facebook ...
func (*Facebook) Authenticate ¶
Authenticate requests the user profile from Facebook
func (*Facebook) GetRemoteUserData ¶
GetRemoteUserData fetched user data from Facebook
func (*Facebook) InitOauthConfig ¶
InitOauthConfig initialize facebook oauth config
type Google ¶
type Google struct { Storage storage.MembershipStorage // contains filtered or unexported fields }
Google ...
func (*Google) Authenticate ¶
Authenticate requests the user profile from Google
func (*Google) GetRemoteUserData ¶
GetRemoteUserData fetched user data from Google
func (*Google) InitOauthConfig ¶
InitOauthConfig initialize google oauth config
type IndexPageQueryStruct ¶
type IndexPageQueryStruct struct { MongoQuery models.MongoQuery Limit int Offset int Sort string Embedded []string ResourceType string Full bool }
IndexPageQueryStruct struct for querying.
type MailController ¶
type MailController struct { HTMLTemplate *template.Template MailService services.MailService }
MailController is the data structure holding HTML template and mail service
func NewMailController ¶
func NewMailController(svc services.MailService, t *template.Template) *MailController
NewMailController is used to new *MailController
func (*MailController) LoadTemplateFiles ¶
func (contrl *MailController) LoadTemplateFiles(filenames ...string)
LoadTemplateFiles is a wrapper function to parse template files
func (*MailController) SendActivation ¶
SendActivation retrieves email and activation link from rqeuest body, and invoke MailService to send activation mail
func (*MailController) SendDonationSuccessMail ¶
type MembershipController ¶
type MembershipController struct {
Storage storage.MembershipStorage
}
MembershipController ...
func NewMembershipController ¶
func NewMembershipController(s storage.MembershipStorage) *MembershipController
NewMembershipController ...
func (*MembershipController) Activate ¶
Activate - validate the reporter account if validated, then sign in successfully, otherwise, sign in unsuccessfully.
func (*MembershipController) ActivateV2 ¶
func (mc *MembershipController) ActivateV2(c *gin.Context)
ActivateV2 - validate the reporter account if validated, then sign in successfully, otherwise, sign in unsuccessfully.
func (*MembershipController) Close ¶
func (mc *MembershipController) Close() error
Close is the method of Controller interface
func (*MembershipController) CreateABookmarkOfAUser ¶
CreateABookmarkOfAUser given userID and bookmark POST body, this func will try to create bookmark record in the bookmarks table, and build the relationship between bookmark and user
func (*MembershipController) CreateADonationOfAUser ¶
Handler for an authenticated user to create an one-time donation
func (*MembershipController) CreateAPeriodicDonationOfAUser ¶
Handler for an authenticated user to create a periodic donation
func (*MembershipController) DeleteABookmarkOfAUser ¶
DeleteABookmarkOfAUser given userID and bookmarkHref, this func will remove the relationship between user and bookmark
func (*MembershipController) GetADonationOfAUser ¶
func (mc *MembershipController) GetADonationOfAUser(c *gin.Context, donationType string) (int, gin.H, error)
GetADonationOfAUser returns a donation of a user
func (*MembershipController) GetBookmarksOfAUser ¶
GetBookmarksOfAUser given userID this func will list all the bookmarks belongs to the user
func (*MembershipController) GetDonationsOfAUser ¶
TODO GetDonationsOfAUser returns the donations list of a user
func (*MembershipController) IsWebPushSubscribed ¶
IsWebPushSubscribed - which handles the HTTP Get request, and try to check if the web push subscription is existed or not
func (*MembershipController) PatchADonationOfAUser ¶
func (mc *MembershipController) PatchADonationOfAUser(c *gin.Context, donationType string) (int, gin.H, error)
PatchADonationOfAUser method Handler for an authenticated user to patch an prime/token/periodic donation
func (*MembershipController) RenewJWT ¶
RenewJWT - validate the old JWT, if validated, then renew a new one
func (*MembershipController) SignIn ¶
SignIn - send email containing sign-in information to the client
func (*MembershipController) SignInV2 ¶
SignInV2 - send email containing sign-in information to the client
func (*MembershipController) SubscribeWebPush ¶
SubscribeWebPush - which handles the HTTP POST request, and try to create a web push subscription record into the persistent database
func (*MembershipController) TokenDispatch ¶
func (mc *MembershipController) TokenDispatch(c *gin.Context)
TokenDispatch returns the `access_token` in payload for frontend server
func (*MembershipController) TokenInvalidate ¶
func (mc *MembershipController) TokenInvalidate(c *gin.Context)
TokenInvalidate deletes the id_token stored in the client side
type MenuItemsController ¶
type MenuItemsController struct{}
MenuItemsController ...
func (MenuItemsController) Retrieve ¶
func (u MenuItemsController) Retrieve(c *gin.Context)
Retrieve ...
type NewsController ¶
type NewsController struct {
Storage storage.NewsStorage
}
NewsController has methods to handle requests which wants posts, topics ... etc news resource.
func NewNewsController ¶
func NewNewsController(s storage.NewsStorage) *NewsController
NewNewsController ...
func (*NewsController) GetAPost ¶
func (nc *NewsController) GetAPost(c *gin.Context)
GetAPost receive HTTP GET method request, and return the certain post.
func (*NewsController) GetATopic ¶
func (nc *NewsController) GetATopic(c *gin.Context)
GetATopic receive HTTP GET method request, and return the certain post.
func (*NewsController) GetAuthors ¶
GetAuthors receive HTTP GET method request, and return the authors. `limit`, `offset` and `sort` are the url query params, which define the rule we retrieve authors from storage.
func (*NewsController) GetCategoriesPosts ¶
func (nc *NewsController) GetCategoriesPosts(c *gin.Context)
GetCategoriesPosts is specifically made for index page. It will return the posts of all the categories.
func (*NewsController) GetIndexPageContents ¶
func (nc *NewsController) GetIndexPageContents(c *gin.Context)
GetIndexPageContents is specifically made for index page. It will return the first fourth sections including latest, editor picks, latest topic and reviews.
func (*NewsController) GetPosts ¶
func (nc *NewsController) GetPosts(c *gin.Context)
GetPosts receive HTTP GET method request, and return the posts. `query`, `limit`, `offset`, `sort` and `full` are the url query params, which define the rule we retrieve posts from storage.
func (*NewsController) GetQueryParam ¶
func (nc *NewsController) GetQueryParam(c *gin.Context) (mq models.MongoQuery, limit int, offset int, sort string, full bool)
GetQueryParam pares url param
func (*NewsController) GetTopics ¶
func (nc *NewsController) GetTopics(c *gin.Context)
GetTopics receive HTTP GET method request, and return the topics. `query`, `limit`, `offset` and `sort` are the url query params, which define the rule we retrieve topics from storage.
func (*NewsController) SearchAuthors ¶
func (nc *NewsController) SearchAuthors(c *gin.Context)
SearchAuthors - search authors from algolia webservice
func (*NewsController) SearchPosts ¶
func (nc *NewsController) SearchPosts(c *gin.Context)
SearchPosts - search posts of authors from algolia webservice
type OAuth ¶
type OAuth struct { Storage storage.MembershipStorage // contains filtered or unexported fields }
OAuth which stores storage connection and oauth config
func (*OAuth) Authenticate ¶
Authenticate handles [google|facebook] oauth of users and redirect them to specific URL they want with Set-Cookie response header which contains JWT
func (*OAuth) BeginOAuth ¶
BeginAuth redirects user to the [facebook|google] authentication(login) page
func (*OAuth) InitFacebookConfig ¶
func (o *OAuth) InitFacebookConfig()
InitGoogleConfig initiates facebook oauth config
func (*OAuth) InitGoogleConfig ¶
func (o *OAuth) InitGoogleConfig()
InitGoogleConfig initiates google oauth config