Nothing special(2): remaining linting

This commit is contained in:
Makis Maropoulos 2016-06-03 05:20:27 +03:00
parent a337b4768d
commit a3f3e7ebd2
4 changed files with 13 additions and 15 deletions

View File

@ -146,7 +146,7 @@ func (ctx *Context) Session() store.IStore {
return ctx.sessionStore
}
// SessionDestroy destroys the whole session, calls the provider's destory and remove the cookie
// SessionDestroy destroys the whole session, calls the provider's destroy and remove the cookie
func (ctx *Context) SessionDestroy() {
if ctx.station.sessionManager != nil {
if store := ctx.Session(); store != nil {

View File

@ -228,7 +228,7 @@ func (c *Cors) Conflicts() string {
// Serve serves the middleware
func (c *Cors) Serve(ctx *iris.Context) {
if ctx.MethodString() == "OPTIONS" {
if ctx.MethodString() == iris.MethodOptions {
c.logf("Serve: Preflight request")
c.handlePreflight(ctx)
// Preflight requests are standalone and should stop the chain as some other
@ -249,7 +249,7 @@ func (c *Cors) Serve(ctx *iris.Context) {
func (c *Cors) handlePreflight(ctx *iris.Context) {
origin := ctx.RequestHeader("Origin")
if ctx.MethodString() != "OPTIONS" {
if ctx.MethodString() != iris.MethodOptions {
c.logf(" Preflight aborted: %s!=OPTIONS", ctx.MethodString())
return
}

View File

@ -1,9 +1,5 @@
package pongo
/* TODO:
1. Find if pongo2 supports layout, it should have extends or something like django but I don't know yet, if exists then do something with the layour parameter in Exeucte/Gzip.
*/
import (
"io"
"io/ioutil"
@ -19,6 +15,7 @@ import (
)
type (
// Engine the pongo2 engine
Engine struct {
Config *config.Template
templateCache map[string]*pongo2.Template
@ -31,6 +28,7 @@ func New(c config.Template) *Engine {
return &Engine{Config: &c, templateCache: make(map[string]*pongo2.Template)}
}
// BuildTemplates builds the templates
func (p *Engine) BuildTemplates() error {
// Add our filters. first
for k, v := range p.Config.Pongo.Filters {
@ -91,9 +89,8 @@ func (p *Engine) buildFromDir() (templateErr error) {
name := filepath.ToSlash(rel)
p.templateCache[name], templateErr = set.FromString(string(buf))
//_, templateErr = p.Templates.FromCache(rel) // use Relative, no from path because it calculates the basedir of the fsLoader
if templateErr != nil {
return templateErr // break the file walk(;)
return templateErr
}
break
}
@ -137,7 +134,7 @@ func (p *Engine) buildFromAsset() error {
break
}
name := filepath.ToSlash(rel)
p.templateCache[name], err = set.FromString(string(buf)) // I don't konw if that will work, yet
p.templateCache[name], err = set.FromString(string(buf))
if err != nil {
templateErr = err
break
@ -167,19 +164,20 @@ func getPongoContext(templateData interface{}) pongo2.Context {
}
func (p *Engine) fromCache(relativeName string) *pongo2.Template {
p.mu.Lock()
p.mu.Lock() // defer is slow
tmpl, ok := p.templateCache[relativeName]
if ok {
p.mu.Unlock() // defer is slow
p.mu.Unlock()
return tmpl
}
p.mu.Unlock() // defer is slow
p.mu.Unlock()
return nil
}
// layout here is unnesecery
// ExecuteWriter executes a templates and write its results to the out writer
// layout here is useless
func (p *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, layout string) error {
if tmpl := p.fromCache(name); tmpl != nil {
return tmpl.ExecuteWriter(getPongoContext(binding), out)

View File

@ -60,7 +60,7 @@ var routes = []route{
func TestRouter(t *testing.T) {
api := iris.New()
for idx, _ := range routes {
for idx := range routes {
r := routes[idx]
if r.Register {
api.HandleFunc(r.Method, r.Path, func(ctx *iris.Context) {