mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-23 14:03:53 +00:00
commit
513ec0814e
0
CNAME → .github/CNAME
vendored
0
CNAME → .github/CNAME
vendored
5
.github/ISSUE_TEMPLATE/bug_report.md
vendored
5
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -18,7 +18,10 @@ assignees: ""
|
||||
```go
|
||||
package main
|
||||
|
||||
func main() {
|
||||
import "github.com/gofiber/fiber"
|
||||
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
// ..
|
||||
}
|
||||
```
|
||||
|
5
.github/ISSUE_TEMPLATE/question.md
vendored
5
.github/ISSUE_TEMPLATE/question.md
vendored
@ -12,7 +12,10 @@ assignees: ""
|
||||
```go
|
||||
package main
|
||||
|
||||
func main() {
|
||||
import "github.com/gofiber/fiber"
|
||||
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
// ..
|
||||
}
|
||||
```
|
||||
|
0
LICENSE → .github/LICENSE
vendored
0
LICENSE → .github/LICENSE
vendored
15
README.md → .github/README.md
vendored
15
README.md → .github/README.md
vendored
@ -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
15
.github/README_de.md
vendored
@ -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
15
.github/README_es.md
vendored
@ -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
15
.github/README_ja.md
vendored
@ -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
15
.github/README_ko.md
vendored
@ -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
15
.github/README_pt.md
vendored
@ -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
15
.github/README_ru.md
vendored
@ -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>
|
||||
|
||||
|
@ -12,4 +12,4 @@ install:
|
||||
- go get -v golang.org/x/lint/golint
|
||||
script:
|
||||
# - golint -set_exit_status ./...
|
||||
- go test -race ./...
|
||||
- go test ./...
|
||||
|
@ -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" + ` ______ __ ______ ______ ______
|
||||
/\ ___\ /\ \ /\ == \ /\ ___\ /\ == \
|
||||
\ \ __\ \ \ \ \ \ __< \ \ __\ \ \ __<
|
||||
@ -48,7 +50,8 @@ var (
|
||||
// Application structure
|
||||
type Application struct {
|
||||
// Server name header
|
||||
Server string
|
||||
Server string
|
||||
// HTTP server struct
|
||||
httpServer *fasthttp.Server
|
||||
// Show fiber banner
|
||||
Banner bool
|
||||
@ -56,7 +59,8 @@ type Application struct {
|
||||
Engine *engine
|
||||
// https://www.nginx.com/blog/socket-sharding-nginx-release-1-9-1/
|
||||
Prefork bool
|
||||
child 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
|
||||
|
@ -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() {
|
||||
|
@ -1 +0,0 @@
|
||||
package fiber
|
5
utils.go
5
utils.go
@ -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)
|
||||
|
@ -1 +0,0 @@
|
||||
package fiber
|
Loading…
x
Reference in New Issue
Block a user