genelet

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 42 Imported by: 0

README

Genelet Go

Genelet Go is a small but self-contained Go web framework for JSON-described CRUD-style web applications. A Genelet app keeps its runtime contract in conf/config.json and per-component component.json files, then supplies generated or hand-written Filter and Model structs for each component.

The framework includes request routing, SQL-backed CRUD helpers, template rendering, hardened cookies, signed auth/session behavior, issuer-based login flows, OAuth1/OAuth2 helpers, CSRF checks for mutating requests, email helpers, and stable numeric framework errors. It is intended to support generated applications without requiring a larger Go web framework.

How It Works

Requests are routed by path:

<Script>/<role>/<tag>/<component>
<Script>/<role>/<tag>/<component>/<id>

config.json defines the script path, roles, chartags, authentication providers, templates, document root, upload settings, and database connection settings. Each component's component.json defines tables, keys, available actions, validation, aliases, groups, fields, foreign-key helpers, and optional next-page model calls.

For a component named question, the application registers factories that return request-local model and filter values:

controller.ModelFactories["question"] = func() interface{} { return &question.Model{} }
controller.FilterFactories["question"] = func() interface{} { return &question.Filter{} }

At request time the controller parses the URL and request body, checks auth, creates the filter and model, fills ARGS, optionally attaches a SQL database handle, executes the requested action, and returns JSON or renders a template depending on the chartag.

Repository Layout

  • *.go - framework runtime.
  • *_test.go - package regression tests.
  • samples/ - small test sample applications, when present.
  • test.conf - test configuration.
  • tmpl.html - test template fixture.
  • user.tbl - test table fixture.

Installation

Use the public Go module:

go get github.com/guruperl/genelet

Import it from generated or hand-written applications:

import "github.com/guruperl/genelet"

Test

Run the local Go test suite:

go test ./...

Some database tests are skipped unless the local MySQL test configuration is present.

Samples

The repository should include a small test sample application that exercises the public framework surface used by generated apps: config loading, component JSON loading, model/filter registration, routing, auth/session behavior, and at least one CRUD-style component.

Using Genelet

  1. Create a Go app with conf/config.json defining Script, Template, Pubrole, Chartags, Roles, and optional DB/auth settings.
  2. For each component, create a component.json with actions, current_table or current_tables, and current_key.
  3. Provide component Filter and Model structs, usually embedding genelet.Filter and genelet.Model.
  4. Bootstrap genelet.Controller from an HTTP entrypoint.
  5. Register component model/filter factories and call http.ListenAndServe.

Generated apps can use no_db for actions that do not need database work and no_method for actions handled entirely by filter/template behavior. JSON chartags return response bodies; HTML-like chartags render templates such as:

<Template>/<role>/<component>/<action>.<tag>

Database support covers MySQL, PostgreSQL, and SQLite through ConnectArray driver names mysql, postgres/postgresql, and sqlite/sqlite3. PostgreSQL placeholders are rebound automatically from Genelet's internal ? style to $1 style. Procedure helpers use MySQL CALL, PostgreSQL SELECT * FROM function(...), and return an unsupported error for SQLite.

Compatibility Notes

Genelet keeps the legacy generated-app surface stable:

  • JSON config.json and component.json are the runtime contract.
  • Numeric framework error codes and messages are preserved.
  • Cookie and signed auth/session behavior are part of the public surface.
  • ARGS, LISTS, OTHER, existing config keys, and nextpage marker names remain part of the generated-app contract.

Documentation

Overview

Package genelet is a genelet package for genelet framework.

Package genelet provides the Go runtime for Genelet web applications.

Index

Constants

This section is empty.

Variables

View Source
var HTTPClient = &http.Client{Timeout: 15 * time.Second}

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) error

func DecodeScoder

func DecodeScoder(text string, CRYPTEXT string) string

func Digest

func Digest(key string, message ...string) string

func Digest64

func Digest64(key string, message ...string) string

func Digesting

func Digesting(key string, message ...string) string

func Do

func Do(method string, url string, form url.Values, header map[string]string) ([]byte, error)

func Do_hash

func Do_hash(method string, url string, form url.Values, header map[string]string) (map[string]interface{}, error)

func EncodeScoder

func EncodeScoder(text string, CRYPTEXT string) string

func EnsurePasswordHash

func EnsurePasswordHash(password string) (string, error)

func Filtering

func Filtering(vs []string, f func(string) bool) []string

func Get

func Get(url string, form url.Values) ([]byte, error)

func Get_hash

func Get_hash(url string, form url.Values) (map[string]interface{}, error)

func Grep

func Grep(vs []string, t string) bool

func HashPassword

func HashPassword(password string) (string, error)

func Index

func Index(vs []string, t string) int

func Int2ip

func Int2ip(ip uint32) string

func Interface2String

func Interface2String(v interface{}) string

func Invoke

func Invoke(any interface{}, name string, args ...interface{}) []reflect.Value

func Invoke0

func Invoke0(any interface{}, name string, args ...interface{})

func InvokeError

func InvokeError(any interface{}, name string, args ...interface{}) error

func InvokeOptionalVoid

func InvokeOptionalVoid(any interface{}, name string, args ...interface{}) error

func InvokeVoid

func InvokeVoid(any interface{}, name string, args ...interface{}) error

func Ip2int

func Ip2int(ip string) uint32

func LogInfo

func LogInfo(message string, fields map[string]interface{})

func Map

func Map(vs []string, f func(string) string) []string

func MultipartRequest

func MultipartRequest(url string, form url.Values, paramName, path string) (*http.Request, error)

func MultipartUpload

func MultipartUpload(url string, form url.Values, header map[string]string, paramName, path string) ([]byte, error)

func NormalizeDriver

func NormalizeDriver(driver string) string

func Oauth1Request

func Oauth1Request(method string, uri string, hash map[string]string, items []string, combined []string, x_li_format string, form url.Values) ([]byte, error)

func Oauth1Sign

func Oauth1Sign(method string, uri string, hash map[string]string, items []string, combined []string, form url.Values) string

func Post

func Post(url string, form url.Values) ([]byte, error)

func PostFile

func PostFile(url string, fn string, header map[string]string) ([]byte, error)

func PostFile_hash

func PostFile_hash(url string, fn string, header map[string]string) (map[string]interface{}, error)

func Post_hash

func Post_hash(url string, form url.Values) (map[string]interface{}, error)

func RebindSQL

func RebindSQL(driver, query string) string

func Scoder

func Scoder(text string, CRYPTEXT string) []byte

func SelectConditionString

func SelectConditionString(extra url.Values, table ...string) (string, []interface{})

func SelectConditionStringSafe

func SelectConditionStringSafe(extra url.Values, table ...string) (string, []interface{}, error)

func SelectLabelString

func SelectLabelString(selectPars interface{}) (string, []string)

func SelectLabelStringSafe

func SelectLabelStringSafe(selectPars interface{}) (string, []string, error)

func SingleConditionString

func SingleConditionString(keyname interface{}, ids []interface{}, extra ...url.Values) (string, []interface{})

func SingleConditionStringSafe

func SingleConditionStringSafe(keyname interface{}, ids []interface{}, extra ...url.Values) (string, []interface{}, error)

func SortMapMd5

func SortMapMd5(secret, md5_name string, q url.Values) string

func Stripchars

func Stripchars(chr, str string) string

func TableString

func TableString(currentTables []Table) string

func TableStringSafe

func TableStringSafe(currentTables []Table) (string, error)

func To_hash

func To_hash(body []byte) (map[string]interface{}, error)

func To_slice

func To_slice(body []byte) ([]map[string]interface{}, error)

func TryInvoke

func TryInvoke(any interface{}, name string, args ...interface{}) (out []reflect.Value, err error)

func Unix_timestamp

func Unix_timestamp() int

func ValidSQLIdentifier

func ValidSQLIdentifier(name string) bool

func ValidateComponent

func ValidateComponent(comp *Component) error

func ValidateSQLIdentifier

func ValidateSQLIdentifier(kind, name string) error

func ValidateSQLIdentifierList

func ValidateSQLIdentifierList(kind string, names []string) error

func ValidateSQLJoinCondition

func ValidateSQLJoinCondition(cond string) error

func ValidateSQLOrderBy

func ValidateSQLOrderBy(order string) error

func ValidateSQLQualifiedIdentifier

func ValidateSQLQualifiedIdentifier(kind, name string) error

func ValidateSQLSelectExpression

func ValidateSQLSelectExpression(expr string) error

Types

type Access

type Access struct {
	Base
	CGI
}

func NewAccess

func NewAccess(base Base) *Access

func (*Access) SetIP

func (self *Access) SetIP() string

func (*Access) SetWhen

func (self *Access) SetWhen() int

func (*Access) Signature

func (self *Access) Signature(fields ...string) string

func (*Access) VerifyCookie

func (self *Access) VerifyCookie(raw string) error

type Apns

type Apns struct {
	Badge       int8
	Sound       string
	DeviceToken string
	Cert        string
	Key         string
	Passphrase  string
}

func (*Apns) Send

func (self *Apns) Send(body string) error

type Base

type Base struct {
	C            *Config
	W            http.ResponseWriter
	R            *http.Request
	RoleValue    string
	ChartagValue string
}

func (*Base) CSRFInput

func (self *Base) CSRFInput() template.HTML

func (*Base) CSRFToken

func (self *Base) CSRFToken() string

func (*Base) Fulfill

func (self *Base) Fulfill() error

func (*Base) GetIP

func (self *Base) GetIP() string

func (*Base) GetProvider

func (self *Base) GetProvider() string

func (*Base) GetRole

func (self *Base) GetRole() Role

func (*Base) SendNocache

func (self *Base) SendNocache(output string)

func (*Base) SendPage

func (self *Base) SendPage(output string)

func (*Base) SendStatusPage

func (self *Base) SendStatusPage(status int, output ...string)

func (*Base) SetCookie

func (self *Base) SetCookie(name string, value string, maxAge ...int)

func (*Base) SetCookieExpire

func (self *Base) SetCookieExpire(name string)

func (*Base) SetCookieSession

func (self *Base) SetCookieSession(name string, value string)

func (*Base) ValidateCSRF

func (self *Base) ValidateCSRF() error

type Beacon

type Beacon struct {
	Controller
	RoleValue    string
	ChartagValue string
	Header       http.Header

	Code     int
	Redirect string
	Content  string
	// contains filtered or unexported fields
}

func NewBeacon

func NewBeacon(controller Controller, role, tag string, header http.Header) (*Beacon, error)

func (*Beacon) Cookies

func (self *Beacon) Cookies() []*http.Cookie

func (*Beacon) GetDirect

func (self *Beacon) GetDirect(in string) error

func (*Beacon) GetMock

func (self *Beacon) GetMock(pars ...string) error

func (*Beacon) LOGIN

func (self *Beacon) LOGIN(args url.Values) error

func (*Beacon) PostMock

func (self *Beacon) PostMock(obj string, args url.Values) error

type CGI

type CGI interface {
	SetIP() string
	SetWhen() int
	Authenticate(string, string) error
}

type Chartag

type Chartag struct {
	ContentType string
	Short       string
	Case        int8
	Challenge   string
	Logged      string
	Logout      string
	Failed      string
}

func (Chartag) CallChallenge

func (self Chartag) CallChallenge() string

func (Chartag) CallFailed

func (self Chartag) CallFailed() string

func (Chartag) CallLogged

func (self Chartag) CallLogged() string

func (Chartag) CallLogout

func (self Chartag) CallLogout() string

type Component

type Component struct {
	Actions map[string]map[string][]string
	Fks     map[string][]string

	Nextpages map[string][]map[string]interface{}

	CurrentTable  string            `json:"current_table"`
	CurrentTables []Table           `json:"current_tables"`
	CurrentKey    string            `json:"current_key"`
	CurrentKeys   []string          `json:"current_keys"`
	CurrentIDAuto string            `json:"current_id_auto"`
	KeyIN         map[string]string `json:"key_in"`

	InsertPars []string          `json:"insert_pars"`
	EditPars   []string          `json:"edit_pars"`
	UpdatePars []string          `json:"update_pars"`
	InsupdPars []string          `json:"insupd_pars"`
	TopicsPars []string          `json:"topics_pars"`
	TopicsHash map[string]string `json:"topics_hash"`

	TotalForce  int `json:"total_force"`
	Empties     string
	Fields      string
	Maxpageno   string
	Totalno     string
	Rowcount    string
	Pageno      string
	Sortreverse string
	Sortby      string
}

func LoadComponent

func LoadComponent(filename string) (*Component, error)

func NewComponent

func NewComponent(filename string) *Component

type Config

type Config struct {
	UploadDir             string
	Template              string
	Pubrole               string
	Secret                string
	ServerURL             string
	CORSOrigins           []string
	UploadURL             string
	ServerPort            string
	DocumentRoot          string
	ProjectRoot           string
	Script                string
	ComponentName         string
	ActionName            string
	DefaultActions        map[string]string
	RoleName              string
	Oauth2s               []string
	Oauth1s               []string
	LoginName             string
	LogoutName            string
	TagName               string
	ProviderName          string
	CallbackName          string
	GoStampName           string
	GoMD5Name             string
	GoURIName             string
	GoProbeName           string
	GoErrName             string
	UploadMaxBytes        int64
	CSRFName              string
	RequestTimeoutSeconds int

	ConnectArray []string
	Blks         map[string]map[string]string
	Chartags     map[string]Chartag
	Roles        map[string]Role
	Errors       map[string]string
	Custom       map[string]string
	Patterns     []Pattern
}

func NewConfig

func NewConfig(filename string) (*Config, error)

func (*Config) DriverName

func (c *Config) DriverName() string

func (*Config) OpenDB

func (c *Config) OpenDB() (*sql.DB, error)

func (*Config) Sendmail

func (self *Config) Sendmail(lists []map[string]interface{}, ARGS url.Values, other map[string]interface{}) error

func (*Config) ValidateLocalRedirect

func (c *Config) ValidateLocalRedirect(raw string) (string, error)

type Controller

type Controller struct {
	C                *Config
	DB               *sql.DB
	DBDriver         string
	Models           map[string]interface{}
	Filters          map[string]interface{}
	Storage          map[string]interface{}
	ModelFactories   map[string]func() interface{}
	FilterFactories  map[string]func() interface{}
	StorageFactories map[string]func() interface{}
	Logger           *zap.Logger
}

func NewController

func NewController(config *Config, db *sql.DB, logger ...*zap.Logger) *Controller

func (*Controller) Handle

func (self *Controller) Handle(obj string, base Base, method string) error

func (*Controller) ServeHTTP

func (self *Controller) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Crud

type Crud struct {
	DBI
	CurrentTable  string  `json:"current_table"`
	CurrentTables []Table `json:"current_tables"`
	LastIDColumn  string
}

func NewCrud

func NewCrud(db *sql.DB, table string, tables []Table) *Crud

func (*Crud) DeleteHash

func (self *Crud) DeleteHash(keyname interface{}, ids []interface{}, extra ...url.Values) error

func (*Crud) EditHash

func (self *Crud) EditHash(lists *[]map[string]interface{}, selectPars interface{}, keyname interface{}, ids []interface{}, extra ...url.Values) error

func (*Crud) InsertHash

func (self *Crud) InsertHash(fieldValues url.Values) error

func (*Crud) InsupdHash

func (self *Crud) InsupdHash(fieldValues url.Values, upd_fieldValues url.Values, keyname interface{}, uniques []string, s_hash *string) error

func (*Crud) InsupdTable

func (self *Crud) InsupdTable(fieldValues url.Values, keyname string, uniques []string, s_hash *string) error

func (*Crud) ReplaceHash

func (self *Crud) ReplaceHash(fieldValues url.Values) error

func (*Crud) TopicsHash

func (self *Crud) TopicsHash(lists *[]map[string]interface{}, selectPars interface{}, extra ...url.Values) error

func (*Crud) TopicsHashOrder

func (self *Crud) TopicsHashOrder(lists *[]map[string]interface{}, selectPars interface{}, order string, extra ...url.Values) error

func (*Crud) TotalHash

func (self *Crud) TotalHash(hash map[string]interface{}, label string, extra ...url.Values) error

func (*Crud) UpdateHash

func (self *Crud) UpdateHash(fieldValues url.Values, keyname interface{}, ids []interface{}, extra ...url.Values) error

func (*Crud) UpdateHashNulls

func (self *Crud) UpdateHashNulls(fieldValues url.Values, keyname interface{}, ids []interface{}, empties []string, extra ...url.Values) error

type DBI

type DBI struct {
	DB       *sql.DB
	Driver   string
	LastID   int64
	Affected int64

	Logger *zap.Logger
}

func (*DBI) DoProc

func (self *DBI) DoProc(hash map[string]interface{}, names []string, procName string, args ...interface{}) error

func (*DBI) DoSQL

func (self *DBI) DoSQL(sql string, args ...interface{}) error

func (*DBI) DoSQLReturning

func (self *DBI) DoSQLReturning(sql string, returnLabel string, args ...interface{}) error

func (*DBI) DoSQLs

func (self *DBI) DoSQLs(sql string, args [][]interface{}) error

func (*DBI) ExecSQL

func (self *DBI) ExecSQL(sql string) error

func (*DBI) GetArgs

func (self *DBI) GetArgs(ARGS url.Values, sql string, args ...interface{}) error

func (*DBI) GetSQL

func (self *DBI) GetSQL(res map[string]interface{}, sql string, args ...interface{}) error

func (*DBI) GetSQLLabel

func (self *DBI) GetSQLLabel(res map[string]interface{}, sql string, selectLabels []string, args ...interface{}) error

func (*DBI) SelectDoProc

func (self *DBI) SelectDoProc(lists *[]map[string]interface{}, hash map[string]interface{}, names []string, procName string, args ...interface{}) error

func (*DBI) SelectDoProcLabel

func (self *DBI) SelectDoProcLabel(lists *[]map[string]interface{}, hash map[string]interface{}, names []string, procName string, selectLabels []string, args ...interface{}) error

func (*DBI) SelectProc

func (self *DBI) SelectProc(lists *[]map[string]interface{}, procName string, args ...interface{}) error

func (*DBI) SelectProcLabel

func (self *DBI) SelectProcLabel(lists *[]map[string]interface{}, procName string, selectLabels []string, args ...interface{}) error

func (*DBI) SelectSQL

func (self *DBI) SelectSQL(lists *[]map[string]interface{}, sql string, args ...interface{}) error

func (*DBI) SelectSQLLabel

func (self *DBI) SelectSQLLabel(lists *[]map[string]interface{}, sql string, selectLabels []string, args ...interface{}) error

func (*DBI) SetDriver

func (self *DBI) SetDriver(driver string)

type Filter

type Filter struct {
	Base
	Action    string
	Component string
	Actions   map[string]map[string][]string
	Fks       map[string][]string
	OTHER     *map[string]interface{}

	Logger *zap.Logger
}

func (*Filter) After

func (self *Filter) After(model *Model) error

func (*Filter) Before

func (self *Filter) Before(model *Model, extra url.Values, nextextra url.Values) error

func (*Filter) GetAll

func (self *Filter) GetAll() (map[string][]string, []string)

func (*Filter) Initialize

func (self *Filter) Initialize(comp *Component, logger ...*zap.Logger)

func (*Filter) Preset

func (self *Filter) Preset() error

func (*Filter) SetAll

func (self *Filter) SetAll(base Base, action string, component string, other *map[string]interface{})

func (*Filter) SetLoginAs

func (self *Filter) SetLoginAs(roleValue, login, uri string, db *sql.DB) error

type Gate

type Gate struct {
	Access
}

func NewGate

func NewGate(base Base) *Gate

func (*Gate) Forbid

func (self *Gate) Forbid() error

func (*Gate) GetAttribute

func (self *Gate) GetAttribute(key string) (string, error)

func (*Gate) GetAttributes

func (self *Gate) GetAttributes(ref map[string]string) error

func (*Gate) HandleLogout

func (self *Gate) HandleLogout() error

func (*Gate) SetAttribute

func (self *Gate) SetAttribute(key string, value string) error

func (*Gate) SetAttributes

func (self *Gate) SetAttributes(ref map[string]string) error

type Gcm

type Gcm struct {
	Api_key          string
	Registration_ids string
	Delay_while_idle string
	Time_to_live     string
	Collapse_key     string
}

func (*Gcm) Send

func (self *Gcm) Send(body string) error

type Gerror

type Gerror struct {
	Code   int
	Errstr string
}

func Err

func Err(code int, str ...string) Gerror

func (Gerror) Error

func (self Gerror) Error() string

func (*Gerror) Refresh

func (self *Gerror) Refresh()

type Issuer

type Issuer struct {
	Default      bool
	Screen       int8
	Sql          string
	Sql_as       string
	PasswordHash string            `json:"Password_hash"`
	ProviderPars map[string]string `json:"Provider_pars"`
	Credential   []string
	InPars       []string
	OutPars      []string
	ConditionURI [][]string
}

type Model

type Model struct {
	Crud
	Context context.Context

	ARGS  url.Values
	LISTS *[]map[string]interface{}
	OTHER *map[string]interface{}

	SORTBY      string
	SORTREVERSE string
	PAGENO      string
	ROWCOUNT    string
	TOTALNO     string
	MAXPAGENO   string
	FIELD       string
	EMPTIES     string

	Nextpages map[string][]map[string]interface{}
	Storage   map[string]interface{}

	CurrentKey    string            `json:"current_key"`
	CurrentKeys   []string          `json:"current_keys"`
	CurrentIDAuto string            `json:"current_id_auto"`
	KeyIN         map[string]string `json:"key_in"`

	InsertPars     []string          `json:"insert_pars"`
	EditPars       []string          `json:"edit_pars"`
	UpdatePars     []string          `json:"update_pars"`
	InsupdPars     []string          `json:"insupd_pars"`
	TopicsPars     []string          `json:"topics_pars"`
	TopicsHashpars map[string]string `json:"topics_hashpars"`

	TotalForce int `json:"total_force"`
}

func (*Model) CallNextpage

func (self *Model) CallNextpage(page map[string]interface{}, extra ...url.Values) error

func (*Model) CallOnce

func (self *Model) CallOnce(page map[string]interface{}, extra ...url.Values) error

func (*Model) Delete

func (self *Model) Delete(extra ...url.Values) error

func (*Model) Edit

func (self *Model) Edit(extra ...url.Values) error

func (*Model) Existing

func (self *Model) Existing(table string, field string, val interface{}) error

func (*Model) GetOrderString

func (self *Model) GetOrderString() string

func (*Model) GetOrderStringChecked

func (self *Model) GetOrderStringChecked() (string, error)

func (*Model) Initialize

func (self *Model) Initialize(comp *Component, logger ...*zap.Logger)

func (*Model) Insert

func (self *Model) Insert(extra ...url.Values) error

Insert use 'extra' to override fieldValues for selected fields

func (*Model) Insupd

func (self *Model) Insupd(extra ...url.Values) error

func (*Model) ProcessAfter

func (self *Model) ProcessAfter(action string, extra ...url.Values) error

func (*Model) ProperValue

func (self *Model) ProperValue(v string, extra url.Values) string

func (*Model) ProperValues

func (self *Model) ProperValues(vs []string, extra url.Values) []string

func (*Model) Randomid

func (self *Model) Randomid(table string, field string, m ...interface{}) error

func (*Model) SetDB

func (self *Model) SetDB(db *sql.DB)

func (*Model) SetDefaults

func (self *Model) SetDefaults(args url.Values, lists *[]map[string]interface{}, other *map[string]interface{}, storage map[string]interface{})

func (*Model) SetDriver

func (self *Model) SetDriver(driver string)

func (*Model) Topics

func (self *Model) Topics(extra ...url.Values) error

func (*Model) Update

func (self *Model) Update(extra ...url.Values) error

type Oauth1

type Oauth1 struct {
	Procedure
	DefaultPars map[string]string
	Combined    []string
	X_li_format string
}

func NewOauth1

func NewOauth1(base Base, db *sql.DB, uri string, provider string) *Oauth1

func (*Oauth1) Authenticate

func (self *Oauth1) Authenticate(login, password string) error

func (*Oauth1) Oauth1_api

func (self *Oauth1) Oauth1_api(method string, uri string, form url.Values) (map[string]interface{}, error)

func (*Oauth1) Oauth1_apis

func (self *Oauth1) Oauth1_apis(method string, uri string, form url.Values) ([]map[string]interface{}, error)

type Oauth2

type Oauth2 struct {
	Procedure
	DefaultPars map[string]string
	AccessToken string
}

func NewOauth2

func NewOauth2(base Base, db *sql.DB, uri string, provider string) *Oauth2

func (*Oauth2) Authenticate

func (self *Oauth2) Authenticate(login, password string) error

func (*Oauth2) Multipart_upload

func (self *Oauth2) Multipart_upload(uri string, form url.Values, paramName, path string) (map[string]interface{}, error)

func (*Oauth2) Multipart_uploads

func (self *Oauth2) Multipart_uploads(uri string, form url.Values, paramName, path string) ([]map[string]interface{}, error)

func (*Oauth2) Oauth2_api

func (self *Oauth2) Oauth2_api(method string, uri string, form url.Values, h map[string]string) (map[string]interface{}, error)

func (*Oauth2) Oauth2_apis

func (self *Oauth2) Oauth2_apis(method string, uri string, form url.Values, h map[string]string) ([]map[string]interface{}, error)

type Pattern

type Pattern struct {
	Reg      string
	Regs     *regexp.Regexp
	Keys     []string
	Initials string
	Expire   int
	Case     PatternCase
}

type PatternCase

type PatternCase int
const (
	REROUTE PatternCase = iota
	CACHE
	STATIC
)

type Procedure

type Procedure struct {
	DB *sql.DB
	Ticket
}

func NewProcedure

func NewProcedure(base Base, db *sql.DB, uri string, provider string) *Procedure

func (*Procedure) Authenticate

func (self *Procedure) Authenticate(login, passwd string) error

func (*Procedure) Authenticate_as

func (self *Procedure) Authenticate_as(login string) error

func (*Procedure) Callback_address

func (self *Procedure) Callback_address() string

func (*Procedure) Fill_provider

func (self *Procedure) Fill_provider(back map[string]interface{}) error

func (*Procedure) Run_sql

func (self *Procedure) Run_sql(call_name string, in_vals []interface{}) error

type Role

type Role struct {
	Id_name    string
	Id_cipher  bool
	Type_id    int
	Is_admin   bool
	Attributes []string

	Coding    string
	Secret    string
	Surface   string
	Length    int8
	Duration  int
	Userlist  []string
	Grouplist []string
	Logout    string
	Domain    string
	Path      string
	MaxAge    int

	Issuers map[string]Issuer
}

type Smtp

type Smtp struct {
	Username string
	Password string
	Address  string
	From     string
	Headers  map[string]string
	To       []string
}

func (*Smtp) Send

func (self *Smtp) Send(headers map[string]string, content string) error

type Smtpssl

type Smtpssl struct {
	Username           string
	Password           string
	Address            string
	Headers            map[string]string
	From               string
	To                 []string
	InsecureSkipVerify bool
}

func (*Smtpssl) Send

func (self *Smtpssl) Send(headers map[string]string, content string) error

type Table

type Table struct {
	Name  string
	Alias string
	Type  string
	Using string
	On    string
}

type Ticket

type Ticket struct {
	Access
	Uri      string
	Provider string
	Out_hash map[string]interface{}
	// each item in condition uri is: variable name, how, variable value, base uri, other variable names wholse values would be passed in the redirect.
	// how: t--out hash, u--go uri, p--provider; A--equal, B--not equal, C--match; 0--no sign, 1--sign;  0--no authen cookie, 1--yes authen cookie
	// for u and p in 'how', 'variable name' will be go_uri that matches
	ConditionURI [][]string
}

func NewTicket

func NewTicket(base Base, uri string, provider string) *Ticket

func (*Ticket) Authenticate

func (self *Ticket) Authenticate(login, password string) error

func (*Ticket) GetAttributes

func (self *Ticket) GetAttributes() []string

func (*Ticket) Handler

func (self *Ticket) Handler() error

func (*Ticket) HandlerFields

func (self *Ticket) HandlerFields() error

func (*Ticket) Handler_login

func (self *Ticket) Handler_login() error

type Tmpl

type Tmpl struct {
	Lists   []map[string]interface{}
	ARGS    url.Values
	Other   map[string]interface{}
	Extra   map[string]interface{}
	Success bool
}

func (*Tmpl) Get_page

func (self *Tmpl) Get_page(T *template.Template) (string, error)

Jump to

Keyboard shortcuts

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