Skip to content

📝 [Proposal]: Create API around app.startupMessage #3800

@Mopsgamer

Description

@Mopsgamer

Feature Proposal Description

fiber.ListenData does not include information such as handler count, PID, child PIDs, process count, or other internal data.

It is difficult, if not impossible, to reproduce the original startup message accurately.
Logging is only possible before the startup message, not immediately after it.

Alignment with Express API

Express does not implement any kind of "startup message" API.

HTTP RFC Standards Compliance

This hook is not part of any HTTP standard.

API Stability

Potentially breaking.

DisableStartupMessage may be kept or removed.
app.startupMessage may be kept, changed, used within an internal wrapper or removed.

Feature Examples

package main

import (
    "time"
    "fmt"

    "github.com/gofiber/fiber/v3"
)

func main() {
    app := fiber.New(fiber.Config{
        DisableStartupMessage: true,
    })

    gitHash := getGitHash() // Custom Git hash retrieval function.

    // Option 1: Modify the OnListen hook.
    app.Hooks().OnListen(func(listenData fiber.ListenData) error {
        // listenData.PreventDefault()
        listenData.UseHeader("FOOBER "+listenData.Version+"\n-------")
        listenData.UsePrimaryInfoMap(fiber.Map{"Git hash": gitHash})
        <-listenData.AfterPrint() // Instead of Pre/Post
        fmt.Println("APP v98")
        return nil
    })

    // Option 2: Add a new OnPrePostStartupMessage hook.
    app.Hooks().OnPreStartupMessage(func(sm fiber.PreStartupMessageData) {
        sm.UseHeader("FOOBER "+sm.Version+"\n-------")
        sm.UsePrimaryInfoMap(fiber.Map{"Git hash": gitHash}) // Note: ANSI colors and ANSI links exist; length should be calculated correctly for alignment.
    })

    app.Hooks().OnPreStartupMessage(func(sm fiber.PreStartupMessageData) {
        sm.PreventDefault() // Potential replacement for DisableStartupMessage.
    })

    app.Hooks().OnPostStartupMessage(func(sm fiber.PostStartupMessageData) {
        fmt.Println("APP v98")
    })

    app.Listen(":5000")
}

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have searched for existing issues that describe my proposal before opening this one.
  • I understand that a proposal that does not meet these guidelines may be closed without explanation.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions