Skip to content

Commit

Permalink
πŸ”₯ FEATURE: Allow adding App Name to customizing the startup message (#…
Browse files Browse the repository at this point in the history
…1418)

* Add Global Layout for view render

* Add test case for Views Layout

* Update ctx_test.go

* Add App Name function to pass custom app name

* Remove json tag for function

* Change func to string

* Add test for AppName

Co-authored-by: RW <[email protected]>
  • Loading branch information
sujit-baniya and ReneWerner87 authored Jul 16, 2021
1 parent c8d0a0c commit 8ab5c65
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ type Config struct {
// Default: false
DisableStartupMessage bool `json:"disable_startup_message"`

// This function allows to setup app name for the app
//
// Default: nil
AppName string `json:"app_name"`

// StreamRequestBody enables request body streaming,
// and calls the handler sooner when given body is
// larger then the current limit.
Expand Down Expand Up @@ -957,9 +962,11 @@ func (app *App) startupMessage(addr string, tls bool, pids string) {
procs = "1"
}

mainLogo := cBlack +
" β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”\n" +
" β”‚ " + centerValue(" Fiber v"+Version, 49) + " β”‚\n"
mainLogo := cBlack + " β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”\n"
if app.config.AppName != "" {
mainLogo += " β”‚ " + centerValue(app.config.AppName, 49) + " β”‚\n"
}
mainLogo += " β”‚ " + centerValue(" Fiber v"+Version, 49) + " β”‚\n"

if host == "0.0.0.0" {
mainLogo +=
Expand Down
6 changes: 6 additions & 0 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,12 @@ func Test_App_Master_Process_Show_Startup_Message(t *testing.T) {
startupMessage(":3000", true, strings.Repeat(",11111,22222,33333,44444,55555,60000", 10))
}

func Test_App_Master_Process_Show_Startup_MessageWithAppName(t *testing.T) {
app := New(Config{Prefork: true, AppName: "Test App v1.0.1"})
app.startupMessage(":3000", true, strings.Repeat(",11111,22222,33333,44444,55555,60000", 10))
utils.AssertEqual(t, "Test App v1.0.1", app.Config().AppName)
}

func Test_App_Server(t *testing.T) {
app := New()

Expand Down

0 comments on commit 8ab5c65

Please sign in to comment.