mirror of https://github.com/gofiber/fiber.git
Add DisableStartupMessage (#314)
* Add crowdin * Update media links * Update README_de.md * Update README_de.md * Update README_de.md * Add crowdin link * Print addr when listening * Print addr on listening * Add DisableStartupMessage * Fix typopull/318/head
parent
7b59c5bf78
commit
4d14679a87
|
@ -1,12 +1,28 @@
|
|||
# Contributing
|
||||
|
||||
When contributing to this repository, please first discuss the change you wish to make via issue, [Gitter](https://gitter.im/gofiber/community) or any other method with the owners of this repository before making a change.
|
||||
When contributing to this repository, please first discuss the change you wish to make via our [Telegram](https://t.me/gofiber) group, by creating an [issue](https://github.com/gofiber/fiber/issues) or any other method with the owners of this repository before making a change.
|
||||
|
||||
Please note: we have a code of conduct, please follow it in all your interactions with the `Fiber` project.
|
||||
Please note: we have a [code of conduct](https://github.com/gofiber/fiber/blob/master/.github/CODE_OF_CONDUCT.md), please follow it in all your interactions with the `Fiber` project.
|
||||
|
||||
## Pull Request Process
|
||||
## Pull Requests or Comits
|
||||
Titles always we must use prefix according to below:
|
||||
|
||||
1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
|
||||
2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
|
||||
3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
|
||||
4. You may merge the Pull Request in once you have the sign-off of two other developers or if you do not have permission to do that, you may request the second reviewer to merge it for you.
|
||||
> 🔥 Feature, ♻️ Refactor, 🩹 Fix, 🚨 Test, 📚 Doc, 🎨 Style
|
||||
- 🔥 Feature: Add flow to add person
|
||||
- ♻️ Refactor: Rename file X to Y
|
||||
- 🩹 Fix: Improve flow
|
||||
- 🚨 Test: Validate to add a new person
|
||||
- 📚 Doc: Translate to Portuguese middleware redirect
|
||||
- 🎨 Style: Respected pattern Golint
|
||||
|
||||
All pull request that contains a feature or fix is mandatory to have unit tests. Your PR is only to be merged if you respect this flow.
|
||||
|
||||
# 👍 Contribute
|
||||
|
||||
If you want to say **thank you** and/or support the active development of `Fiber`:
|
||||
|
||||
1. Add a [GitHub Star](https://github.com/gofiber/fiber/stargazers) to the project.
|
||||
2. Tweet about the project [on your Twitter](https://twitter.com/intent/tweet?text=%F0%9F%9A%80%20Fiber%20%E2%80%94%20is%20an%20Express.js%20inspired%20web%20framework%20build%20on%20Fasthttp%20for%20%23Go%20https%3A%2F%2Fgithub.com%2Fgofiber%2Ffiber).
|
||||
3. Write a review or tutorial on [Medium](https://medium.com/), [Dev.to](https://dev.to/) or personal blog.
|
||||
4. Help us to translate our API Documentation via [Crowdin](https://crowdin.com/project/gofiber) [](https://crowdin.com/project/gofiber)
|
||||
5. Support the project by donating a [cup of coffee](https://buymeacoff.ee/fenny).
|
38
app.go
38
app.go
|
@ -58,6 +58,8 @@ type Settings struct {
|
|||
DisableDefaultDate bool // default: false
|
||||
// When set to true, causes the default Content-Type header to be excluded from the Response.
|
||||
DisableDefaultContentType bool // default: false
|
||||
// When set to true, it will not print out the fiber ASCII and "listening" on message
|
||||
DisableStartupMessage bool
|
||||
// Folder containing template files
|
||||
TemplateFolder string // default: ""
|
||||
// Template engine: html, amber, handlebars , mustache or pug
|
||||
|
@ -339,8 +341,10 @@ func (app *App) Serve(ln net.Listener, tlsconfig ...*tls.Config) error {
|
|||
ln = tls.NewListener(ln, tlsconfig[0])
|
||||
}
|
||||
// Print listening message
|
||||
fmt.Printf(" _______ __\n ____ / ____(_) /_ ___ _____\n_____ / /_ / / __ \\/ _ \\/ ___/\n __ / __/ / / /_/ / __/ /\n /_/ /_/_.___/\\___/_/ v%s\n", Version)
|
||||
fmt.Printf("Started listening on %s\n", ln.Addr().String())
|
||||
if !app.Settings.DisableStartupMessage {
|
||||
fmt.Printf(" _______ __\n ____ / ____(_) /_ ___ _____\n_____ / /_ / / __ \\/ _ \\/ ___/\n __ / __/ / / /_/ / __/ /\n /_/ /_/_.___/\\___/_/ v%s\n", Version)
|
||||
fmt.Printf("Started listening on %s\n", ln.Addr().String())
|
||||
}
|
||||
return app.server.Serve(ln)
|
||||
}
|
||||
|
||||
|
@ -378,7 +382,7 @@ func (app *App) Listen(address interface{}, tlsconfig ...*tls.Config) error {
|
|||
ln = tls.NewListener(ln, tlsconfig[0])
|
||||
}
|
||||
// Print listening message
|
||||
if !isChild() {
|
||||
if !app.Settings.DisableStartupMessage && !isChild() {
|
||||
fmt.Printf(" _______ __\n ____ / ____(_) /_ ___ _____\n_____ / /_ / / __ \\/ _ \\/ ___/\n __ / __/ / / /_/ / __/ /\n /_/ /_/_.___/\\___/_/ v%s\n", Version)
|
||||
fmt.Printf("Started listening on %s\n", ln.Addr().String())
|
||||
}
|
||||
|
@ -400,15 +404,12 @@ func (app *App) Shutdown() error {
|
|||
}
|
||||
|
||||
// Test is used for internal debugging by passing a *http.Request
|
||||
// Timeout is optional and defaults to 200ms, -1 will disable it completely.
|
||||
// Timeout is optional and defaults to 1s, -1 will disable it completely.
|
||||
func (app *App) Test(request *http.Request, msTimeout ...int) (*http.Response, error) {
|
||||
timeout := 200
|
||||
timeout := 1000 // 1 second default
|
||||
if len(msTimeout) > 0 {
|
||||
timeout = msTimeout[0]
|
||||
}
|
||||
if timeout < 0 {
|
||||
timeout = 60000 // 1 minute
|
||||
}
|
||||
// Dump raw http request
|
||||
dump, err := httputil.DumpRequest(request, true)
|
||||
if err != nil {
|
||||
|
@ -428,13 +429,22 @@ func (app *App) Test(request *http.Request, msTimeout ...int) (*http.Response, e
|
|||
channel <- app.server.ServeConn(conn)
|
||||
}()
|
||||
// Wait for callback
|
||||
select {
|
||||
case err := <-channel:
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if timeout >= 0 {
|
||||
// With timeout
|
||||
select {
|
||||
case err = <-channel:
|
||||
case <-time.After(time.Duration(timeout) * time.Millisecond):
|
||||
return nil, fmt.Errorf("Timeout error %vms", timeout)
|
||||
}
|
||||
case <-time.After(time.Duration(timeout) * time.Millisecond):
|
||||
return nil, fmt.Errorf("Timeout error")
|
||||
} else {
|
||||
// Without timeout
|
||||
select {
|
||||
case err = <-channel:
|
||||
}
|
||||
}
|
||||
// Check for errors
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Read response
|
||||
buffer := bufio.NewReader(&conn.w)
|
||||
|
|
14
ctx_test.go
14
ctx_test.go
|
@ -135,11 +135,6 @@ func Test_Body(t *testing.T) {
|
|||
if result != expect {
|
||||
t.Fatalf(`%s: Expecting %s, got %s`, t.Name(), expect, result)
|
||||
}
|
||||
expect = "doe"
|
||||
result = c.Body("john")
|
||||
if result != expect {
|
||||
t.Fatalf(`%s: Expecting %s, got %s`, t.Name(), expect, result)
|
||||
}
|
||||
})
|
||||
data := url.Values{}
|
||||
data.Set("john", "doe")
|
||||
|
@ -201,13 +196,8 @@ func Test_BodyParser(t *testing.T) {
|
|||
func Test_Cookies(t *testing.T) {
|
||||
app := New()
|
||||
app.Get("/test", func(c *Ctx) {
|
||||
expect := "john=doe"
|
||||
result := c.Cookies()
|
||||
if result != expect {
|
||||
t.Fatalf(`%s: Expecting %s, got %s`, t.Name(), expect, result)
|
||||
}
|
||||
expect = "doe"
|
||||
result = c.Cookies("john")
|
||||
expect := "doe"
|
||||
result := c.Cookies("john")
|
||||
if result != expect {
|
||||
t.Fatalf(`%s: Expecting %s, got %s`, t.Name(), expect, result)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue