flaskgo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2018 License: Apache-2.0 Imports: 13 Imported by: 1

README

FlaskGo - Go web framework inspired by Python Flask

Usage

var app = flaskgo.CreateApp()
app.AddRoute("/index", func() string { return "This is Index page" })
app.AddRoute("/indexDyna1/<int:id>/<path:path>", func(id int, path string) string { return "abc" })
app.Run(":8080")

Documentation

Index

Constants

View Source
const PAGE_NOT_FOUND = `` /* 233-byte string literal not displayed */
View Source
const PS = `(?P<static>[^<]*)<(?:(?P<converter>[a-zA-Z_][a-zA-Z0-9_]*)(?:\((?P<args>.*?)\))?\:)?(?P<variable>[a-zA-Z_][a-zA-Z0-9_]*)>`

Variables

This section is empty.

Functions

func GetFileContent

func GetFileContent(fullFilePath string) []byte

func GetRequest

func GetRequest() *http.Request

func GetResponseWriter

func GetResponseWriter() http.ResponseWriter

func Redirect

func Redirect(location string) func()

func SetFileContentProvider

func SetFileContentProvider(f FileContentProvider)

func UseMemoryFile

func UseMemoryFile(fileMap map[string][]byte)

Types

type App

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

func CreateApp

func CreateApp() App

func CreateAppWithPrefix

func CreateAppWithPrefix(prefix string) App

func (*App) AddRoute

func (app *App) AddRoute(rule string, handler interface{}, methods ...string)

func (*App) AddRouteAll

func (app *App) AddRouteAll(prefix string, target interface{})

func (*App) Handler

func (app *App) Handler(w http.ResponseWriter, r *http.Request)

func (*App) Redirect

func (app *App) Redirect(location string) func()

func (*App) RenderTemplate

func (app *App) RenderTemplate(name string, context *Context) string

func (*App) Run

func (app *App) Run(address string)

type BooleanConverter

type BooleanConverter struct {
}

func (*BooleanConverter) Parse

func (c *BooleanConverter) Parse(input string) Object

func (*BooleanConverter) Pattern

func (c *BooleanConverter) Pattern() string

type Context

type Context map[string]Object

type Converter

type Converter interface {
	Pattern() string
	Parse(input string) Object
}

func GetConverter

func GetConverter(name string) Converter

type DefaultConverter

type DefaultConverter struct {
}

func (*DefaultConverter) Parse

func (c *DefaultConverter) Parse(input string) Object

func (*DefaultConverter) Pattern

func (c *DefaultConverter) Pattern() string

type DefaultFileContentProvider

type DefaultFileContentProvider struct {
}

func (*DefaultFileContentProvider) GetFileContent

func (f *DefaultFileContentProvider) GetFileContent(fullFilePath string) []byte

type DynamicRouteFunc

type DynamicRouteFunc interface{}

type FileContentProvider

type FileContentProvider interface {
	GetFileContent(fullFilePath string) []byte
}

type FileTemplate

type FileTemplate struct {
	TplName string
}

func (*FileTemplate) Content

func (t *FileTemplate) Content() string

func (*FileTemplate) Name

func (t *FileTemplate) Name() string

func (*FileTemplate) Type

func (t *FileTemplate) Type() string

type IntConverter

type IntConverter struct {
}

func (*IntConverter) Parse

func (c *IntConverter) Parse(input string) Object

func (*IntConverter) Pattern

func (c *IntConverter) Pattern() string

type MemoryFileContentProvider

type MemoryFileContentProvider struct {
	FileMap map[string][]byte
}

func (*MemoryFileContentProvider) GetFileContent

func (m *MemoryFileContentProvider) GetFileContent(fullFilePath string) []byte

type Object

type Object interface {
}

type Parameters

type Parameters map[string]Object

func (Parameters) Int

func (p Parameters) Int(key string) int

func (Parameters) String

func (p Parameters) String(key string) string

type PathConverter

type PathConverter struct {
}

func (*PathConverter) Parse

func (c *PathConverter) Parse(input string) Object

func (*PathConverter) Pattern

func (c *PathConverter) Pattern() string

type RPS

type RPS []RulePart

func (RPS) String

func (r RPS) String() string

type Router

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

func (Router) Parameters

func (router Router) Parameters(real []string, keywords []string) (Parameters, []Object)

type RulePart

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

func (*RulePart) String

func (r *RulePart) String() string

type StaticRouteFunc

type StaticRouteFunc interface{}

type Template

type Template interface {
	Name() string
	Type() string
	Content() string
}

type VarPair

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

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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