Skip to content

Go API ​

Preá is a set of Go modules. A project created by prea new depends on the root module, which brings the others. The complete API of each one, with every type and function, is on pkg.go.dev.

ModuleWhat it has
github.com/prea-framework/preaRun and Test, Config, Logging
…/coreModule, App, Router, Middleware, Security, CORS, CSRF, Server, Reply, Error, NewError, RequestLogger, Recovery
…/dithe container: Export, Named, MissingError
…/databaseBaseRepository, Prepare, Statement, Args, Transactional, the errors, Setup and the migrations
…/configLoad, Config.Value, Config.Profile
…/securityNewJwt, CheckSignKey, HashPassword, ComparePassword, ErrInvalidToken, ErrPasswordTooLong
…/loggerDebug, Info, Success, Error, Configure, New
…/cmd/preathe CLI

Using a module on its own ​

Each module has its own version and its own dependencies. An app that only needs HTTP and components can depend on core alone, without the database driver or the token library:

bash
go get github.com/prea-framework/prea/core

It then builds a core.App itself, instead of calling prea.Run:

go
app := core.App{
	Modules:  []*core.Module{task.Module},
	Security: core.Security{Headers: core.DefaultHeaders},
}
if err := app.Run(":8000"); err != nil {
	log.Fatal(err)
}

Versions ​

Each module is tagged on its own, with its folder as a prefix: core/v0.0.2, cmd/prea/v0.0.2. The root module's tags have no prefix: v0.0.2. Every module shares the same major version.

Released under the MIT License.