polaris

package module
v0.0.0-...-ea61863 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2014 License: MIT Imports: 11 Imported by: 0

README

polaris

a restful web framework like tornado written by go

see my chinese blog for more

Example

type Handler1 struct {

}

func (h *Handler1) Prepare(env *Env) {
    fmt.Println("hello prepare")
}

func (h *Handler1) Get(env *Env) {
    env.WriteString("hello world")
}

type Handler2 struct {

}

//id is a captured submatch for regexp url below
func (h *Handler2) Get(env *Env, id string) {
    env.WriteString("hello " + id)
}

app := NewApp(configFile)

app.Handle("/handler1", new(Handler1))
app.Handle("/handler2/([0-9]+)", new(Handler2))

app.Run()

Dependence

go get github.com/garyburd/redigo/redis

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAppRunning = errors.New("app is running, cannot set")
)
View Source
var SupportMethods = []string{"Prepare", "Get", "Post", "Put", "Head", "Delete"}

Functions

This section is empty.

Types

type App

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

func NewApp

func NewApp(configFile string) (*App, error)

func (*App) Config

func (app *App) Config() *Config

func (*App) Handle

func (app *App) Handle(pattern string, handler interface{}) error

func (*App) Run

func (app *App) Run() error

type Config

type Config struct {
	//polaris listen addr
	HttpAddr string `json:"http_addr"`

	Middlewares []struct {
		Name   string          `json:"name"`
		Config json.RawMessage `json:"config"`
	} `json:"middlewares"`
}

func ParserConfig

func ParserConfig(configFile string) (*Config, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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