goKLC

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 12 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRoute

func GetRoute(name string) string

func NewRouteNameList

func NewRouteNameList() routeNameList

Types

type App

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

func GetApp

func GetApp() *App

func (*App) Assets

func (a *App) Assets(path string) string

func (*App) Auth

func (a *App) Auth() *Auth

func (*App) Config

func (a *App) Config() Config

func (*App) DB

func (a *App) DB() *gorm.DB

func (*App) GetDBURL

func (a *App) GetDBURL(dbType DBType) string

func (*App) GetRouteByName

func (a *App) GetRouteByName(name string) string

func (*App) GetSessionKey

func (a *App) GetSessionKey() string

func (*App) Log

func (a *App) Log() Log

func (*App) Middleware

func (a *App) Middleware(m MiddlewareInterface)

func (*App) Route

func (a *App) Route() Route

func (*App) Run

func (a *App) Run()

func (*App) ServeHTTP

func (a *App) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*App) SetDB

func (a *App) SetDB(db *gorm.DB)

func (*App) SetLogger

func (a *App) SetLogger(logger Log)

type Auth

type Auth struct {
	Model ModelInterface
}

func (*Auth) Check

func (a *Auth) Check(request *Request) bool

func (*Auth) LoginById

func (a *Auth) LoginById(id int, request *Request)

func (*Auth) User

func (a *Auth) User(request *Request) ModelInterface

type Config

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

func NewConfig

func NewConfig() Config

func (Config) Get

func (c Config) Get(key string, defaultValue interface{}) interface{}

func (Config) Set

func (c Config) Set(key string, value interface{})

func (Config) SetFromMap

func (c Config) SetFromMap(config map[string]interface{})

type Context

type Context map[string]interface{}

type Controller

type Controller struct{}

type ControllerFunc

type ControllerFunc func(*Request) *Response
type Cookie struct {
	Name     string
	Value    string
	Duration int
	Path     string
	// contains filtered or unexported fields
}

func NewCookie

func NewCookie() *Cookie

func (*Cookie) Get

func (c *Cookie) Get(r *Request, name string) (bool, *Cookie)

func (*Cookie) Set

func (c *Cookie) Set(r *Response)

type DBType

type DBType string
const MSSQL DBType = "mssql"
const MYSQL DBType = "mysql"
const NONE DBType = "none"
const POSTGRES DBType = "postgres"
const SQLITE3 DBType = "sqlite3"

type Log

type Log interface {
	Debug(message string, context map[string]interface{})
	Info(message string, context map[string]interface{})
	Notice(message string, context map[string]interface{})
	Warning(message string, context map[string]interface{})
	Error(message string, context map[string]interface{})
	Critical(message string, context map[string]interface{})
	Alert(message string, context map[string]interface{})
	Emergency(message string, context map[string]interface{})
}

type Method

type Method string
const DELETE Method = "DELETE"
const GET Method = "GET"
const PATCH Method = "PATCH"
const POST Method = "POST"
const PUT Method = "PUT"

type Middleware

type Middleware struct {
}

func NewMiddleware

func NewMiddleware() *Middleware

func (Middleware) Handle

func (m Middleware) Handle(request *Request) *Response

func (Middleware) Terminate

func (m Middleware) Terminate(response *Response)

type MiddlewareInterface

type MiddlewareInterface interface {
	Handle(request *Request) *Response
	Terminate(request *Response)
}

type MiddlewareNode

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

func NewMiddlewareNode

func NewMiddlewareNode() *MiddlewareNode

func (*MiddlewareNode) AddChild

func (node *MiddlewareNode) AddChild(childNode *MiddlewareNode)

func (*MiddlewareNode) AddParent

func (node *MiddlewareNode) AddParent(parentNode *MiddlewareNode)

func (*MiddlewareNode) Child

func (node *MiddlewareNode) Child() *MiddlewareNode

func (*MiddlewareNode) Handle

func (node *MiddlewareNode) Handle(request *Request) (*Response, *MiddlewareNode)

func (*MiddlewareNode) Parent

func (node *MiddlewareNode) Parent() *MiddlewareNode

func (*MiddlewareNode) Terminate

func (node *MiddlewareNode) Terminate(response *Response)

type ModelInterface

type ModelInterface interface {
}

type Request

type Request struct {
	Request *http.Request
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(req *http.Request, routeParams RouteParams) *Request

func (*Request) GetParameter

func (r *Request) GetParameter(key string) interface{}

func (*Request) Input

func (r *Request) Input(key string) []string

func (*Request) Json

func (r *Request) Json(dataModel *interface{})

type Response

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

func NewResponse

func NewResponse() *Response

func (*Response) AddCookie

func (r *Response) AddCookie(c *Cookie) *Response

func (*Response) Error

func (r *Response) Error(content string) *Response

func (*Response) Ok

func (r *Response) Ok(content string) *Response

type Route

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

func NewRoute

func NewRoute() Route

func (Route) Delete

func (r Route) Delete(address string, controller ControllerFunc) *Route

func (Route) Get

func (r Route) Get(address string, controller ControllerFunc) *Route

func (Route) Group

func (r Route) Group(prefix string) *RouteGroup

func (*Route) Middleware

func (r *Route) Middleware(m MiddlewareInterface) *Route

func (*Route) Name

func (r *Route) Name(name string) *Route

func (Route) Patch

func (r Route) Patch(address string, controller ControllerFunc) *Route

func (Route) Post

func (r Route) Post(address string, controller ControllerFunc) *Route

func (Route) Put

func (r Route) Put(address string, controller ControllerFunc) *Route

type RouteGroup

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

func NewRouteGroup

func NewRouteGroup() RouteGroup

func (RouteGroup) Group

func (rg RouteGroup) Group(prefix string) RouteGroup

func (*RouteGroup) Middleware

func (rg *RouteGroup) Middleware(m MiddlewareInterface) *RouteGroup

func (*RouteGroup) Name

func (rg *RouteGroup) Name(name string) *RouteGroup

func (*RouteGroup) Route

func (rg *RouteGroup) Route() Route

type RouteNode

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

func NewRouteTree

func NewRouteTree() *RouteNode

func (*RouteNode) AddChild

func (node *RouteNode) AddChild(key string, route *Route) *RouteNode

func (*RouteNode) AddFromPath

func (node *RouteNode) AddFromPath(path []string, route *Route)

func (*RouteNode) AddNext

func (node *RouteNode) AddNext(key string, route *Route) *RouteNode

func (*RouteNode) FindFromPath

func (node *RouteNode) FindFromPath(path []string) (*RouteNode, RouteParams)

func (*RouteNode) FindNext

func (node *RouteNode) FindNext(key string) *RouteNode

func (*RouteNode) GetRoute

func (node *RouteNode) GetRoute() *Route

type RouteParams

type RouteParams map[string]interface{}

type Session

type Session struct {
	Id    string
	Key   string
	Value interface{}

	Duration time.Duration
	// contains filtered or unexported fields
}

func NewSession

func NewSession(r *Request) *Session

func (*Session) Delete

func (s *Session) Delete()

func (*Session) Get

func (s *Session) Get(key string, defaultValue interface{}) interface{}

func (*Session) Set

func (s *Session) Set()

type SessionInterface

type SessionInterface interface {
	Set(key string, value interface{})
	Get(key string, defaultValue interface{}) interface{}
	Delete()
}

type View

type View struct {
	Filename string
	Context  Context
}

func NewView

func NewView(fileName string, context Context) *View

func (*View) Render

func (v *View) Render() string

Jump to

Keyboard shortcuts

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