Documentation ¶
Index ¶
- Variables
- func ActionLimitMiddleware(conf ActionLimitConf) echo.MiddlewareFunc
- func AdminOnlyHandler(next echo.HandlerFunc) echo.HandlerFunc
- func AllowedComment(c echo.Context, p ParamsGet) func(db *gorm.DB) *gorm.DB
- func AllowedCommentChecker(c echo.Context, p ParamsGet) func(*model.Comment) bool
- func CheckIsAdminReq(c echo.Context) bool
- func CheckIsAllowed(c echo.Context, name string, email string, page model.Page, siteName string) (bool, error)
- func CheckOrigin(c echo.Context, allowSite *model.Site) (bool, error)
- func CommentSearchScope(a *action, p ParamsGet) func(d *gorm.DB) *gorm.DB
- func CopyStruct(src *map[string]interface{}, dest *map[string]interface{}) error
- func CountComments(db *gorm.DB) int64
- func DisposeImageCaptcha(ip string)
- func GetAlwaysCaptchaMode_Pass(ip string) bool
- func GetCommentQuery(a *action, c echo.Context, p ParamsGet, siteID uint, ...) *gorm.DB
- func GetImageCaptchaRealCode(ip string) string
- func GetIsAllowOrigin(origin string, allowURLs []string) bool
- func GetIsSuperAdmin(c echo.Context) bool
- func GetJwtInstanceByReq(c echo.Context) *jwt.Token
- func GetJwtStrByReqCookie(c echo.Context) string
- func GetNewImageCaptchaBase64(ip string) string
- func GetSortRuleSQL(sortBy string, defaultSQL string) string
- func GetUserByJwt(jwt *jwt.Token) model.User
- func GetUserByReq(c echo.Context) model.User
- func HashPassword(password string) (string, error)
- func InitCorsControl(e *echo.Echo)
- func InitRouter(e *echo.Echo)
- func IsActionInTimeFrame(c echo.Context) bool
- func IsAdminHasSiteAccess(c echo.Context, siteName string) bool
- func IsReqNeedCaptchaCheck(c echo.Context) bool
- func LogWithHttpInfo(c echo.Context) *logrus.Entry
- func LoginGetUserToken(user model.User) string
- func Paginate(offset int, limit int) func(db *gorm.DB) *gorm.DB
- func ParamsDecode(c echo.Context, destParams interface{}) (isContinue bool, resp error)
- func RecordAction(c echo.Context)
- func RenotifyWhenPendingModified(comment *model.Comment)
- func ResetActionRecord(c echo.Context)
- func RespData(c echo.Context, data interface{}) error
- func RespError(c echo.Context, msg string, data ...Map) error
- func RespJSON(c echo.Context, msg string, data interface{}, success bool) error
- func RespSuccess(c echo.Context, msg ...string) error
- func RootComments() func(db *gorm.DB) *gorm.DB
- func RootPageMiddleware() echo.MiddlewareFunc
- func Run()
- func SetAlwaysCaptchaMode_Pass(ip string, pass bool)
- func SiteIsolationChecker(c echo.Context, p ParamsGet) func(*model.Comment) bool
- func SiteIsolationScope(c echo.Context, p ParamsGet) func(db *gorm.DB) *gorm.DB
- func SiteOriginMiddleware() echo.MiddlewareFunc
- func UseCfgFrontend(p *ParamsGet)
- func UseSite(c echo.Context, siteName *string, destID *uint, destSiteAll *bool)
- func VoteSync(a *action)
- type ActionLimitConf
- type JSONResult
- type Map
- type ParamsAdd
- type ParamsAdminCacheFlush
- type ParamsAdminCacheWarm
- type ParamsAdminImport
- type ParamsAdminPageDel
- type ParamsAdminPageEdit
- type ParamsAdminPageFetch
- type ParamsAdminPageGet
- type ParamsAdminSendMail
- type ParamsAdminSettingSave
- type ParamsAdminSiteAdd
- type ParamsAdminSiteDel
- type ParamsAdminSiteEdit
- type ParamsAdminSiteGet
- type ParamsAdminUserAdd
- type ParamsAdminUserDel
- type ParamsAdminUserEdit
- type ParamsAdminUserGet
- type ParamsAdminVoteSync
- type ParamsCaptchaCheck
- type ParamsCommentDel
- type ParamsCommentEdit
- type ParamsGet
- type ParamsImgUpload
- type ParamsLogin
- type ParamsLoginStatus
- type ParamsMarkRead
- type ParamsPV
- type ParamsStat
- type ParamsUserGet
- type ParamsVote
- type ResponseAdd
- type ResponseAdminPageGet
- type ResponseAdminUserGet
- type ResponseGet
- type Skipper
Constants ¶
This section is empty.
Variables ¶
View Source
var (
CaptchaExpiration = 5 * time.Minute // 验证码 5 分钟内有效
)
View Source
var ImgUpload_RoutePath = "/static/images/"
图片目录路由重写路径
View Source
var SiteOriginSkips = []string{
"/api/user-get",
"/api/login",
}
不启用 Origin 控制的 API paths
Functions ¶
func ActionLimitMiddleware ¶
func ActionLimitMiddleware(conf ActionLimitConf) echo.MiddlewareFunc
操作限制 中间件
func AdminOnlyHandler ¶
func AdminOnlyHandler(next echo.HandlerFunc) echo.HandlerFunc
func AllowedComment ¶
允许的评论
func AllowedCommentChecker ¶
func CheckIsAdminReq ¶
func CheckIsAdminReq(c echo.Context) bool
func CheckIsAllowed ¶
func CheckOrigin ¶
检测 Origin 合法性 防止跨域的 CSRF 攻击 @see https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
func CommentSearchScope ¶
评论搜索
func CopyStruct ¶
func GetAlwaysCaptchaMode_Pass ¶
AlwaysMode 是否能 Pass (for 总是需要验证码的选项)
func GetCommentQuery ¶
func GetCommentQuery(a *action, c echo.Context, p ParamsGet, siteID uint, scopes ...func(*gorm.DB) *gorm.DB) *gorm.DB
获取评论查询实例
func GetImageCaptchaRealCode ¶
#region 图片验证码 获取对应 IP 图片验证码正确的值
func GetIsAllowOrigin ¶
判断 Origin 是否被允许 origin is 'schema://hostname:port', allowURLs is a collection of url strings
func GetIsSuperAdmin ¶
func GetIsSuperAdmin(c echo.Context) bool
func GetJwtInstanceByReq ¶
func GetJwtStrByReqCookie ¶
func GetJwtStrByReqCookie(c echo.Context) string
func GetUserByReq ¶
func HashPassword ¶
func InitCorsControl ¶
func InitCorsControl(e *echo.Echo)
func InitRouter ¶
func InitRouter(e *echo.Echo)
func IsAdminHasSiteAccess ¶
func LogWithHttpInfo ¶
func LoginGetUserToken ¶
func ParamsDecode ¶
func RespData ¶
func RespData(c echo.Context, data interface{}) error
RespData is just response data
func RespSuccess ¶
RespSuccess is just response success
func RootPageMiddleware ¶
func RootPageMiddleware() echo.MiddlewareFunc
func SetAlwaysCaptchaMode_Pass ¶
设置 AlwaysMode 允许 Pass (for 总是需要验证码的选项)
func SiteIsolationChecker ¶
func SiteIsolationScope ¶
站点隔离
Types ¶
type ActionLimitConf ¶
type ActionLimitConf struct {
ProtectPaths []string
}
type JSONResult ¶
type JSONResult struct { Success bool `json:"success"` // 是否成功 Msg string `json:"msg,omitempty"` // 消息 Data interface{} `json:"data,omitempty"` // 数据 Extra interface{} `json:"extra,omitempty"` // 数据 }
JSONResult JSON 响应数据结构
type Map ¶
type Map = map[string]interface{}
func GetApiPublicConfDataMap ¶
func GetApiPublicConfDataMap(c echo.Context) Map
func GetApiVersionDataMap ¶
func GetApiVersionDataMap() Map
type ParamsAdd ¶
type ParamsAdd struct { Name string `mapstructure:"name"` Email string `mapstructure:"email"` Link string `mapstructure:"link"` Content string `mapstructure:"content" param:"required"` Rid uint `mapstructure:"rid"` UA string `mapstructure:"ua"` PageKey string `mapstructure:"page_key" param:"required"` PageTitle string `mapstructure:"page_title"` Token string `mapstructure:"token"` SiteName string SiteID uint }
type ParamsAdminCacheFlush ¶
type ParamsAdminCacheFlush struct {
FlushAll bool `mapstructure:"flush_all"`
}
type ParamsAdminCacheWarm ¶
type ParamsAdminCacheWarm struct { }
type ParamsAdminImport ¶
type ParamsAdminImport struct {
Payload string `mapstructure:"payload"`
}
type ParamsAdminPageDel ¶
type ParamsAdminPageEdit ¶
type ParamsAdminPageFetch ¶
type ParamsAdminPageGet ¶
type ParamsAdminSendMail ¶
type ParamsAdminSettingSave ¶
type ParamsAdminSettingSave struct {
Data string `mapstructure:"data" param:"required"`
}
type ParamsAdminSiteAdd ¶
type ParamsAdminSiteDel ¶
type ParamsAdminSiteDel struct {
ID uint `mapstructure:"id" param:"required"`
}
type ParamsAdminSiteEdit ¶
type ParamsAdminSiteGet ¶
type ParamsAdminSiteGet struct { }
type ParamsAdminUserAdd ¶
type ParamsAdminUserAdd struct { Name string `mapstructure:"name" param:"required"` Email string `mapstructure:"email" param:"required"` Password string `mapstructure:"password"` Link string `mapstructure:"link"` IsAdmin bool `mapstructure:"is_admin" param:"required"` SiteNames string `mapstructure:"site_names"` ReceiveEmail bool `mapstructure:"receive_email" param:"required"` BadgeName string `mapstructure:"badge_name"` BadgeColor string `mapstructure:"badge_color"` }
type ParamsAdminUserDel ¶
type ParamsAdminUserDel struct {
ID uint `mapstructure:"id" param:"required"`
}
type ParamsAdminUserEdit ¶
type ParamsAdminUserEdit struct { // 查询值 ID uint `mapstructure:"id" param:"required"` // 修改值 Name string `mapstructure:"name" param:"required"` Email string `mapstructure:"email" param:"required"` Password string `mapstructure:"password"` Link string `mapstructure:"link"` IsAdmin bool `mapstructure:"is_admin" param:"required"` SiteNames string `mapstructure:"site_names"` ReceiveEmail bool `mapstructure:"receive_email" param:"required"` BadgeName string `mapstructure:"badge_name"` BadgeColor string `mapstructure:"badge_color"` }
type ParamsAdminUserGet ¶
type ParamsAdminVoteSync ¶
type ParamsAdminVoteSync struct { }
type ParamsCaptchaCheck ¶
type ParamsCaptchaCheck struct {
Value string `mapstructure:"value" param:"required"`
}
type ParamsCommentDel ¶
type ParamsCommentEdit ¶
type ParamsCommentEdit struct { // 查询值 ID uint `mapstructure:"id" param:"required"` SiteName string SiteID uint SiteAll bool // 可修改 Content string `mapstructure:"content"` PageKey string `mapstructure:"page_key"` Nick string `mapstructure:"nick"` Email string `mapstructure:"email"` Link string `mapstructure:"link"` Rid string `mapstructure:"rid"` UA string `mapstructure:"ua"` IP string `mapstructure:"ip"` IsCollapsed bool `mapstructure:"is_collapsed"` IsPending bool `mapstructure:"is_pending"` IsPinned bool `mapstructure:"is_pinned"` }
type ParamsGet ¶
type ParamsGet struct { PageKey string `mapstructure:"page_key" param:"required"` SiteName string Limit int `mapstructure:"limit"` Offset int `mapstructure:"offset"` FlatMode bool `mapstructure:"flat_mode"` SortBy string `mapstructure:"sort_by"` // date_asc, date_desc, vote ViewOnlyAdmin bool `mapstructure:"view_only_admin"` // 只看 admin Search string `mapstructure:"search"` // Message Center Type string `mapstructure:"type"` // ["", "all", "mentions", "mine", "pending", "admin_all", "admin_pending"] Name string `mapstructure:"name"` Email string `mapstructure:"email"` SiteID uint SiteAll bool IsMsgCenter bool User *model.User IsAdminReq bool }
type ParamsImgUpload ¶
type ParamsLogin ¶
type ParamsLoginStatus ¶
type ParamsMarkRead ¶
type ParamsStat ¶
type ParamsUserGet ¶
type ParamsVote ¶
type ResponseAdd ¶
type ResponseAdd struct {
Comment model.CookedComment `json:"comment"`
}
type ResponseAdminPageGet ¶
type ResponseAdminPageGet struct { Total int64 `json:"total"` Pages []model.CookedPage `json:"pages"` }
type ResponseAdminUserGet ¶
type ResponseAdminUserGet struct { Total int64 `json:"total"` Users []model.CookedUserForAdmin `json:"users"` }
type ResponseGet ¶
type ResponseGet struct { Comments []model.CookedComment `json:"comments"` Total int64 `json:"total"` TotalRoots int64 `json:"total_roots"` Page model.CookedPage `json:"page"` Unread []model.CookedNotify `json:"unread"` UnreadCount int `json:"unread_count"` ApiVersion Map `json:"api_version"` Conf Map `json:"conf,omitempty"` }
Source Files ¶
- a_action.go
- a_http.go
- a_permission.go
- a_resp.go
- a_router.go
- a_site_origin.go
- admin.go
- admin_cache.go
- admin_comment_del.go
- admin_comment_edit.go
- admin_page_del.go
- admin_page_edit.go
- admin_page_fetch.go
- admin_page_get.go
- admin_send_mail.go
- admin_setting.go
- admin_site_add.go
- admin_site_del.go
- admin_site_edit.go
- admin_site_get.go
- admin_transfer.go
- admin_user_add.go
- admin_user_del.go
- admin_user_edit.go
- admin_user_get.go
- admin_vote_sync.go
- captcha.go
- comment_add.go
- comment_get.go
- comment_get_query.go
- img_upload.go
- mark_read.go
- pv.go
- stat.go
- user_get.go
- user_login.go
- user_logout.go
- utils.go
- vote.go
Click to show internal directories.
Click to hide internal directories.