app

package
v0.0.0-...-f83d065 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package app serves

Index

Constants

View Source
const (
	ErrCodeParams = iota + 100
	ErrCodeDBFailed
	ErrMarshalFailed
)

Error codes

Variables

View Source
var (
	ErrInvalidExportType  = NewError(1001, errors.New("Invalid export type"))
	ErrInvalidAccessToken = NewError(1002, errors.New("Invalid access token"))
)

Definition of errors

Functions

func Callback

func Callback(auth *infra.Authenticator) gin.HandlerFunc

Callback handler

func Login

func Login(auth *infra.Authenticator) gin.HandlerFunc

Login handler

Types

type AddParams

type AddParams struct {
	Token       string `form:"token" binding:"required"`
	Title       string `form:"title" binding:"required"`
	URL         string `form:"url" binding:"required,url"`
	Type        string `form:"type" binding:"required,oneof=read unread skip skim"`
	Author      string `form:"author"`
	Description string `form:"description"`
	Device      string `form:"device"`
}

AddParams .

type Application

type Application struct {
	// contains filtered or unexported fields
}

Application globals

func (Application) Add

func (app Application) Add(c *gin.Context)

Add implementation of adding an article

func (Application) AutoMigrate

func (app Application) AutoMigrate() error

AutoMigrate migrate gorm DB

func (Application) Conf

func (app Application) Conf() *infra.Conf

Conf getter

func (Application) DB

func (app Application) DB() *gorm.DB

DB returns DB instance

func (Application) Dashboard

func (app Application) Dashboard(c *gin.Context)

Dashboard .

func (Application) Export

func (app Application) Export(c *gin.Context)

Export data

func (Application) GetUserInfo

func (app Application) GetUserInfo(ctx *gin.Context) *model.User

GetUserInfo .

func (Application) Index

func (app Application) Index(c *gin.Context)

Index .

func (*Application) Init

func (app *Application) Init(workingPath string) error

Init globals

func (Application) IsAuthenticated

func (app Application) IsAuthenticated(ctx *gin.Context)

IsAuthenticated .

func (Application) List

func (app Application) List(c *gin.Context)

List .

func (Application) LoadRoutes

func (app Application) LoadRoutes(r *gin.Engine) error

LoadRoutes .

func (Application) Logout

func (app Application) Logout(ctx *gin.Context)

Logout handler .

func (Application) RenderHTML

func (app Application) RenderHTML(c *gin.Context, template string, bindings liquid.Bindings) error

RenderHTML with Liquid

func (Application) Setup

func (app Application) Setup(c *gin.Context)

Setup .

type DashboardParams

type DashboardParams struct {
	Year  int `form:"year"`
	Month int `form:"month"`
	Day   int `form:"day"`
}

DashboardParams .

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error .

func NewError

func NewError(code int, err error) *Error

NewError .

func (Error) Response

func (ae Error) Response() Response

Response returns error response

type ExportParams

type ExportParams struct {
	Year   int    `form:"year"`
	Month  int    `form:"month"`
	Format string `form:"format" binding:"required,oneof=json yaml"`
}

ExportParams .

type ListParams

type ListParams struct {
	Year  int `form:"year"`
	Month int `form:"month"`
}

ListParams .

type Response

type Response struct {
	Code    int         `json:"Code"`
	Message string      `json:"Message"`
	Data    interface{} `json:"Data,omitempty"`
}

Response .

func NewResponse

func NewResponse() *Response

NewResponse creates a new response body

func (*Response) SetCode

func (r *Response) SetCode(code int)

SetCode .

func (*Response) SetData

func (r *Response) SetData(data interface{})

SetData .

func (*Response) SetMessage

func (r *Response) SetMessage(msg string)

SetMessage .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL