44 lines
819 B
Go
44 lines
819 B
Go
package di
|
|
|
|
import (
|
|
"net/http"
|
|
"pink_fox/inner/storage"
|
|
"pink_fox/inner/view"
|
|
"pink_fox/packages/fw"
|
|
)
|
|
|
|
type Container struct {
|
|
storage *storage.Storage
|
|
writer http.ResponseWriter
|
|
request *http.Request
|
|
}
|
|
|
|
func MakeContainer(storage *storage.Storage, writer http.ResponseWriter, request *http.Request) *Container {
|
|
return &Container{
|
|
storage: storage,
|
|
writer: writer,
|
|
request: request,
|
|
}
|
|
}
|
|
|
|
func CloseContainer(_ *Container) {
|
|
}
|
|
|
|
func (it *Container) Debug() bool {
|
|
return it.storage.Debug
|
|
}
|
|
|
|
func (it *Container) Logger() fw.Logger {
|
|
return nil // FIXME
|
|
}
|
|
|
|
func (it *Container) ResponseFactory() *fw.ResponseFactory {
|
|
return fw.NewResponseFactory(it.writer, it.storage.Template, func() any {
|
|
return view.NewView()
|
|
})
|
|
}
|
|
|
|
func (it *Container) GetWriter() http.ResponseWriter {
|
|
return it.writer
|
|
}
|