Documentation ΒΆ
Index ΒΆ
- func FileServer(r *chi.Mux, path string, root http.FileSystem)
- func FileServerStatic(r *chi.Mux, path string)
- func PrintLogo(logoFile string)
- func WaitAndStopServer(server *http.Server)
- type Builder
- type Injector
- func (injector Injector) Add(builder Builder)
- func (injector Injector) CallBuilder(builder Builder) interface{}
- func (injector Injector) Get(name interface{}) interface{}
- func (injector Injector) GetByType(name reflect.Type) interface{}
- func (injector Injector) PopulateStruct(userStruct interface{})
- func (injector Injector) ResolveHandler(builder Builder) http.HandlerFunc
- func (injector Injector) ShowAvailableBuilders()
- type Present
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func FileServer ΒΆ added in v0.16.2
func FileServer(r *chi.Mux, path string, root http.FileSystem)
FileServer creates using a router, a url path and a file path a file server.
func FileServerStatic ΒΆ added in v0.16.2
func FileServerStatic(r *chi.Mux, path string)
FileServerStatic creates a file server with your desired path a file server that serves files in ./static folder.
func PrintLogo ΒΆ added in v0.16.0
func PrintLogo(logoFile string)
PrintLogo takes a file path and prints your fancy ascii logo. It will fail if your file is not found.
func WaitAndStopServer ΒΆ added in v0.16.0
WaitAndStopServer gives you a way to gracefully stop your server.
Types ΒΆ
type Builder ΒΆ added in v0.11.0
type Builder interface{}
Builder is a function that expects nothing and retuns the type that builds. The type cant be func() interface{} cause some errors appears in runtime. So it's represented as an interface.
type Injector ΒΆ added in v0.11.0
type Injector struct {
// contains filtered or unexported fields
}
Injector is an automated dependency injector inspired in Sping's DI. It will detect which builder to call using its return type. If the builder haver params, it will fullfill that params calling other builders that provides its types.
func (Injector) CallBuilder ΒΆ added in v0.11.0
CallBuilder injecting all parameters with provided builders. If some parameter type cannot be found, it will panic
func (Injector) Get ΒΆ added in v0.11.0
func (injector Injector) Get(name interface{}) interface{}
Get returns a builded dependency
func (Injector) GetByType ΒΆ added in v0.11.0
GetByType returns a builded dependency identified by type
func (Injector) PopulateStruct ΒΆ added in v0.11.0
func (injector Injector) PopulateStruct(userStruct interface{})
PopulateStruct fills a struct with the implementations that the injector can create. Make sure you pass a reference and not a value
func (Injector) ResolveHandler ΒΆ added in v0.16.2
func (injector Injector) ResolveHandler(builder Builder) http.HandlerFunc
ResolveHandler created by a builder
func (Injector) ShowAvailableBuilders ΒΆ added in v0.11.0
func (injector Injector) ShowAvailableBuilders()
ShowAvailableBuilders prints all registered builders.
type Present ΒΆ added in v0.31.0
type Present func(data interface{}, errs error)
func JSONPresenter ΒΆ added in v0.13.0
func JSONPresenter(w http.ResponseWriter, req *http.Request) Present