goaltools / goal

Goal is a toolkit for high productivity web development in Go language in the spirit of Revel Framework that is built around the concept of code generation.
BSD 2-Clause "Simplified" License
87 stars 3 forks source link

fix new Controller instance is failed #46

Closed mei-rune closed 8 years ago

mei-rune commented 8 years ago

old code is

func (t tControllers) newC(w http.ResponseWriter, r *http.Request, ctr, act string) *contr.Controllers {
    // Allocate a new controller. Set values of special fields, if necessary.
    c := &contr.Controllers{}

    // Allocate its parents. Make sure controller of every type
    // is allocated just once, then reused.
    c.Templates = c.Errors.Templates
    c.Errors = &c5.Errors{}
    c.Static = &c3.Static{}
    c.Sessions = &c2.Sessions{

        Request: r,

        Response: w,
    }
    c.Requests = &c1.Requests{

        Request: r,

        Response: w,
    }
    c.Global = &c0.Global{

        CurrentAction: act,

        CurrentController: ctr,
    }
    c.Errors.Templates = &c4.Templates{}
    c.Errors.Templates.Requests = c.Requests
    c.Errors.Templates.Global = c.Global
    c.Templates.Requests = c.Requests
    c.Templates.Global = c.Global

    return c
}

new code is


func (t tControllers) newC(w http.ResponseWriter, r *http.Request, ctr, act string) *contr.Controllers {
    // Allocate a new controller. Set values of special fields, if necessary.
    c := &contr.Controllers{}

    // Allocate its parents. Make sure controller of every type
    // is allocated just once, then reused.
    c.Templates = &c4.Templates{}
    c.Errors = &c5.Errors{}
    c.Static = &c3.Static{}
    c.Sessions = &c2.Sessions{

        Request: r,

        Response: w,
    }
    c.Requests = &c1.Requests{

        Request: r,

        Response: w,
    }
    c.Global = &c0.Global{

        CurrentAction: act,

        CurrentController: ctr,
    }
    c.Errors.Templates = c.Templates
    c.Templates.Requests = c.Requests
    c.Templates.Global = c.Global

    return c
}