phoenix

package module
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 13 Imported by: 0

README ΒΆ

🐦 Phoenix

My tiny library to make webapps. Includes: DI, renderers and a bucnh of usefull functions

Documentation ΒΆ

Index ΒΆ

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(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

func WaitAndStopServer(server *http.Server)

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 NewInjector ΒΆ added in v0.11.0

func NewInjector() *Injector

NewInjector with default values

func (Injector) Add ΒΆ added in v0.11.0

func (injector Injector) Add(builder Builder)

Add a builder to the dependency injector.

func (Injector) CallBuilder ΒΆ added in v0.11.0

func (injector Injector) CallBuilder(builder Builder) interface{}

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

func (injector Injector) GetByType(name reflect.Type) interface{}

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

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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