Skip to content

v1.1.0 codefluence-x renaming, jsonapi package and other additional feature

Compare
Choose a tag to compare
@insomnius insomnius released this 31 Aug 16:29
· 5 commits to main since this release

Highlight

  1. Change codefluence-x branding into kodefluence
  2. New jsonapi package which follow the standards of https://jsonapi.org.
  3. More exception type

Change diff.

Important Notes

We're change our package name into kodefluence. This would be full rebranding for all of our repository and others.


Changes

Added

JSONAPI

jsonapi work as a standard grpc or http response. Usage:

Create new json response.

jsonapi.BuildResponse(jsonapi.WithData(map[string]interface{}{
    "name": "testing",
}))

It would results with this output

{"data":{"name":"testing"}}

Create new json error response with exception

exc1 := exception.Throw(
	errors.New("unexpected error"),
	exception.WithDetail("detail"),
	exception.WithTitle("title"),
)

exc2 := exception.Throw(
	errors.New("unexpected error"),
	exception.WithDetail("detail_2"),
	exception.WithTitle("title_2"),
)

jsonapi.BuildResponse(
	jsonapi.WithException("ERR401", http.StatusNotFound, exc1),
	jsonapi.WithExceptionMeta("ERR401", http.StatusNotFound, exc2, jsonapi.Meta{
		"sample": "sample",
	}),
	jsonapi.WithMeta("show_error", true),
)

Exception

Create 2 new exception, to support more dynamic exception error.

exception.Unauthorized
exception.Forbidden

DB

Add new GetInstance method to get previously defined databases.

sqldb, err = db.FabricateMySQL("main_db", config, db.WithConnMaxLifetime(time.Second), db.WithMaxIdleConn(100), db.WithMaxOpenConn(100))
sqldbvalue, err := db.GetInstance("main_db")