core

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const NamespaceHeaderName = "G-N-ID"

NamespaceHeaderName namespace cookie name

Variables

View Source
var (
	AssetDir string
)

Trans Translator

View Source
var Validate *validator.Validate

Validate use a single instance of Validate, it caches struct info

Functions

func CreateValidator

func CreateValidator()

CreateValidator create a single Validator

func GetAssetDir added in v1.1.4

func GetAssetDir() string

GetAssetDir if env = 'production' return absolute else return relative

func GetConfigFile added in v1.4.2

func GetConfigFile() string

func GetProjectFilePath added in v1.1.3

func GetProjectFilePath(projectID int64) string

func GetProjectPath added in v1.0.3

func GetProjectPath(projectID int64) string

func GetRepositoryPath added in v1.0.3

func GetRepositoryPath() string

func GetTerminalLogPath added in v1.4.6

func GetTerminalLogPath(tlID int64) string

func Log

func Log(lv LogLevel, content string)

Log information to file with logged day

func Logf added in v1.8.0

func Logf(lv LogLevel, format string, a ...interface{})

Types

type Goploy

type Goploy struct {
	UserInfo  model.User
	Namespace struct {
		ID            int64
		PermissionIDs map[int64]struct{}
	}
	Request        *http.Request
	ResponseWriter http.ResponseWriter
	URLQuery       url.Values
	Body           []byte
}

type LogLevel

type LogLevel string

LogLevel is log level

const (
	TRACE   LogLevel = "TRACE: "
	WARNING LogLevel = "WARNING: "
	INFO    LogLevel = "INFO: "
	ERROR   LogLevel = "ERROR: "
)

log level

type Response

type Response interface {
	Write(http.ResponseWriter, *http.Request) error
}

type Route added in v1.4.3

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

func NewRoute added in v1.4.3

func NewRoute(pattern, method string, callback func(gp *Goploy) Response) Route

func NewWhiteRoute added in v1.4.6

func NewWhiteRoute(pattern, method string, callback func(gp *Goploy) Response) Route

func (Route) LogFunc added in v1.4.6

func (r Route) LogFunc(f func(gp *Goploy, resp Response)) Route

LogFunc callback finished

func (Route) Middleware added in v1.4.3

func (r Route) Middleware(middleware func(gp *Goploy) error) Route

Middleware global Middleware handle function

func (Route) Permissions added in v1.6.0

func (r Route) Permissions(permissionIDs ...int64) Route

type RouteApi added in v1.4.3

type RouteApi interface {
	Routes() []Route
}

type Router

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

Router is Route slice and global middlewares

func NewRouter added in v1.4.0

func NewRouter() Router

func (Router) Add

func (rt Router) Add(ra RouteApi) Router

Add pattern path callback where path should be handled

func (Router) Middleware

func (rt Router) Middleware(middleware func(gp *Goploy) error)

Middleware global Middleware handle function

func (Router) ServeHTTP

func (rt Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (Router) Start

func (rt Router) Start()

Start a router

Jump to

Keyboard shortcuts

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