1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-23 14:03:53 +00:00

Merge pull request #124 from Fenny/master

Add supporters
This commit is contained in:
Fenny 2020-02-11 22:59:55 -05:00 committed by GitHub
commit 513ec0814e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 143 additions and 31 deletions

View File

View File

@ -18,7 +18,10 @@ assignees: ""
```go
package main
func main() {
import "github.com/gofiber/fiber"
func main() {
app := fiber.New()
// ..
}
```

View File

@ -12,7 +12,10 @@ assignees: ""
```go
package main
func main() {
import "github.com/gofiber/fiber"
func main() {
app := fiber.New()
// ..
}
```

View File

View File

@ -243,7 +243,20 @@ If you want to say **thank you** and/or support the active development of `fiber
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" style="height: 35px !important;" ></a>
### ⭐️ Stars
## ☕ Supporters
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
</a>
</td>
</tr>
</table>
## ⭐️ Stars
<a href="https://starchart.cc/gofiber/fiber" rel="nofollow"><img src="https://starchart.cc/gofiber/fiber.svg" alt="Stars over time" style="max-width:100%;"></a>

15
.github/README_de.md vendored
View File

@ -243,7 +243,20 @@ Falls du **danke** sagen möchtest und/oder aktiv die Entwicklung von `fiber` f
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" style="height: 35px !important;" ></a>
### ⭐️ Sterne
## ☕ Supporters
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
</a>
</td>
</tr>
</table>
## ⭐️ Sterne
<a href="https://starchart.cc/gofiber/fiber" rel="nofollow"><img src="https://starchart.cc/gofiber/fiber.svg" alt="Stars over time" style="max-width:100%;"></a>

15
.github/README_es.md vendored
View File

@ -242,7 +242,20 @@ Si quiere **agradecer** y / o apoyar el desarrollo activo de la `fiber` :
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" style="height: 35px !important;"></a>
### ⭐️ estrellas
## ☕ Supporters
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
</a>
</td>
</tr>
</table>
## ⭐️ estrellas
<a href="https://starchart.cc/gofiber/fiber" rel="nofollow"><img src="https://starchart.cc/gofiber/fiber.svg" alt="Stars over time" style="max-width:100%;"></a>

15
.github/README_ja.md vendored
View File

@ -242,7 +242,20 @@ func main() {
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" style="height: 35px !important;"></a>
### ⭐️ スター
## ☕ Supporters
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
</a>
</td>
</tr>
</table>
## ⭐️ スター
<a href="https://starchart.cc/gofiber/fiber" rel="nofollow"><img src="https://starchart.cc/gofiber/fiber.svg" alt="Stars over time" style="max-width:100%;"></a>

15
.github/README_ko.md vendored
View File

@ -243,7 +243,20 @@ func main() {
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" style="height: 35px !important;" ></a>
### ⭐️ Stars
## ☕ Supporters
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
</a>
</td>
</tr>
</table>
## ⭐️ Stars
<a href="https://starchart.cc/gofiber/fiber" rel="nofollow"><img src="https://starchart.cc/gofiber/fiber.svg" alt="Stars over time" style="max-width:100%;"></a>

15
.github/README_pt.md vendored
View File

@ -243,7 +243,20 @@ Se você quer **agradecer** e/ou apoiar o desenvolvimento ativo do `fiber` :
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" style="height: 35px !important;"></a>
### ⭐️ Estrelas
## ☕ Supporters
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
</a>
</td>
</tr>
</table>
## ⭐️ Estrelas
<a href="https://starchart.cc/gofiber/fiber" rel="nofollow"><img src="https://starchart.cc/gofiber/fiber.svg" alt="Stars over time" style="max-width:100%;"></a>

15
.github/README_ru.md vendored
View File

@ -242,7 +242,20 @@ func main() {
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" style="height: 35px !important;"></a>
### ⭐️ Звезды
## ☕ Supporters
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
</a>
</td>
</tr>
</table>
## ⭐️ Звезды
<a href="https://starchart.cc/gofiber/fiber" rel="nofollow"><img src="https://starchart.cc/gofiber/fiber.svg" alt="Stars over time" style="max-width:100%;"></a>

View File

@ -12,4 +12,4 @@ install:
- go get -v golang.org/x/lint/golint
script:
# - golint -set_exit_status ./...
- go test -race ./...
- go test ./...

View File

@ -29,8 +29,10 @@ import (
)
const (
// Version : Fiber version
Version = "1.4.3"
// Version : Fiber release
Version = "1.4.4"
// Website : Fiber documentation
Website = "https://fiber.wiki"
banner = "\x1b[1;32m" + ` ______ __ ______ ______ ______
/\ ___\ /\ \ /\ == \ /\ ___\ /\ == \
\ \ __\ \ \ \ \ \ __< \ \ __\ \ \ __<
@ -49,6 +51,7 @@ var (
type Application struct {
// Server name header
Server string
// HTTP server struct
httpServer *fasthttp.Server
// Show fiber banner
Banner bool
@ -56,6 +59,7 @@ type Application struct {
Engine *engine
// https://www.nginx.com/blog/socket-sharding-nginx-release-1-9-1/
Prefork bool
// is child process
child bool
// Stores all routes
routes []*Route
@ -274,6 +278,7 @@ func (app *Application) Static(args ...string) {
prefix := "/"
root := "./"
wildcard := false
midware := false
// enable / disable gzipping somewhere?
// todo v2.0.0
gzip := true
@ -293,11 +298,9 @@ func (app *Application) Static(args ...string) {
// app.Static("/*", "./public/index.html")
if prefix == "*" || prefix == "/*" {
wildcard = true
}
// Check if root exists
if _, err := os.Lstat(root); err != nil {
log.Fatal("Static: ", err)
} else if strings.Contains(prefix, "*") {
prefix = strings.Replace(prefix, "*", "", -1)
midware = true
}
// Lets get all files from root
@ -321,22 +324,18 @@ func (app *Application) Static(args ...string) {
path := filepath.Join(prefix, strings.Replace(file, mount, "", 1))
// for windows: static\index.html => /index.html
path = filepath.ToSlash(path)
// Store absolute file path to use in ctx handler
var filePath string
var err error
if filePath, err = filepath.Abs(file); err != nil {
log.Fatal("Static: ", err)
}
// Store file path to use in ctx handler
filePath := file
// If the file is an index.html, bind the prefix to index.html directly
if filepath.Base(filePath) == "index.html" || filepath.Base(filePath) == "index.htm" {
app.routes = append(app.routes, &Route{"GET", prefix, wildcard, false, nil, nil, func(c *Ctx) {
app.routes = append(app.routes, &Route{"GET", prefix, midware, wildcard, nil, nil, func(c *Ctx) {
c.SendFile(filePath, gzip)
}})
}
// Add the route + SendFile(filepath) to routes
app.routes = append(app.routes, &Route{"GET", path, wildcard, false, nil, nil, func(c *Ctx) {
app.routes = append(app.routes, &Route{"GET", path, midware, wildcard, nil, nil, func(c *Ctx) {
c.SendFile(filePath, gzip)
}})
}
@ -426,7 +425,7 @@ func (app *Application) Test(req *http.Request) (*http.Response, error) {
return nil, err
}
// Throw timeout error after 200ms
case <-time.After(500 * time.Millisecond):
case <-time.After(1000 * time.Millisecond):
return nil, fmt.Errorf("timeout")
}
// Get raw HTTP response

View File

@ -45,9 +45,10 @@ func Test_Methods(t *testing.T) {
func Test_Static(t *testing.T) {
app := New()
app.Static("/yesyes*", ".github/FUNDING.yml")
app.Static("./.github")
app.Static("/john", "./.github")
app.Static("*", "./.github/stale.yml")
req, _ := http.NewRequest("GET", "/stale.yml", nil)
resp, err := app.Test(req)
if err != nil {
@ -59,6 +60,17 @@ func Test_Static(t *testing.T) {
if resp.Header.Get("Content-Length") == "" {
t.Fatalf(`%s: Missing Content-Length`, t.Name())
}
req, _ = http.NewRequest("GET", "/yesyes/john/doe", nil)
resp, err = app.Test(req)
if err != nil {
t.Fatalf(`%s: %s`, t.Name(), err)
}
if resp.StatusCode != 200 {
t.Fatalf(`%s: StatusCode %v`, t.Name(), resp.StatusCode)
}
if resp.Header.Get("Content-Length") == "" {
t.Fatalf(`%s: Missing Content-Length`, t.Name())
}
req, _ = http.NewRequest("GET", "/john/stale.yml", nil)
resp, err = app.Test(req)
if err != nil {
@ -105,6 +117,7 @@ func Test_Group(t *testing.T) {
}
// func Test_Listen(t *testing.T) {
// t.Parallel()
// app := New()
// app.Banner = false
// go func() {

View File

@ -1 +0,0 @@
package fiber

View File

@ -9,6 +9,7 @@ package fiber
import (
"bytes"
"fmt"
"net"
"os"
"path/filepath"
@ -60,6 +61,10 @@ func getRegex(path string) (*regexp.Regexp, error) {
func getFiles(root string) (files []string, isDir bool, err error) {
root = filepath.Clean(root)
// Check if dir/file exists
if _, err := os.Lstat(root); err != nil {
return files, isDir, fmt.Errorf("%s", err)
}
err = filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
files = append(files, path)

View File

@ -1 +0,0 @@
package fiber