diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index aaf8ecb74c..513b75ab9f 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -6,10 +6,10 @@ on: - master - main paths: - - "**.md" + - "**/*.md" pull_request: paths: - - "**.md" + - "**/*.md" jobs: markdownlint: @@ -23,18 +23,3 @@ jobs: with: globs: | **/*.md - - - name: Run write-good - id: write-good - uses: tomwhross/write-good-action@v1.6 - - - run: echo "${{ steps.write-good.outputs.result }}" - - - name: Post suggestions to Pull Request - uses: mshick/add-pr-comment@v2 - if: ${{ steps.write-good.outputs.result }} - with: - message: | - ${{ steps.write-good.outputs.result }} - repo-token: ${{ secrets.GITHUB_TOKEN }} - allow-repeats: false diff --git a/docs/intro.md b/docs/intro.md index 2fd92a37fd..10e94b3dd6 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -183,8 +183,3 @@ http://localhost:3000/hello.html http://localhost:3000/js/jquery.js http://localhost:3000/css/style.css ``` - -### Note - -For more information on how to build APIs in Go with Fiber, please check out this excellent article -[on building an express-style API in Go with Fiber](https://blog.logrocket.com/express-style-api-go-fiber/). diff --git a/docs/whats_new.md b/docs/whats_new.md index fd01c4a698..9155792f6b 100644 --- a/docs/whats_new.md +++ b/docs/whats_new.md @@ -7,7 +7,7 @@ toc_max_heading_level: 3 :::caution -Its a draft, not finished yet. +It's a draft, not finished yet. ::: diff --git a/middleware/adaptor/README.md b/middleware/adaptor/README.md deleted file mode 100644 index 8bacab410a..0000000000 --- a/middleware/adaptor/README.md +++ /dev/null @@ -1,139 +0,0 @@ -# Adaptor - -## Install - -```bash -go get -u github.com/gofiber/fiber/v3 -go get -u github.com/gofiber/fiber/middleware/adaptor -``` - -## Functions - -| Name | Signature | Description -| :--- | :--- | :--- -| HTTPHandler | `HTTPHandler(h http.Handler) fiber.Handler` | http.Handler -> fiber.Handler -| HTTPHandlerFunc | `HTTPHandlerFunc(h http.HandlerFunc) fiber.Handler` | http.HandlerFunc -> fiber.Handler -| HTTPMiddleware | `HTTPHandlerFunc(mw func(http.Handler) http.Handler) fiber.Handler` | func(http.Handler) http.Handler -> fiber.Handler -| FiberHandler | `FiberHandler(h fiber.Handler) http.Handler` | fiber.Handler -> http.Handler -| FiberHandlerFunc | `FiberHandlerFunc(h fiber.Handler) http.HandlerFunc` | fiber.Handler -> http.HandlerFunc -| FiberApp | `FiberApp(app *fiber.App) http.HandlerFunc` | Fiber app -> http.HandlerFunc - -## net/http to Fiber - -```go -package main - -import ( - "fmt" - "net/http" - - "github.com/gofiber/adaptor/v2" - "github.com/gofiber/fiber/v3" -) - -func main() { - // New fiber app - app := fiber.New() - - // http.Handler -> fiber.Handler - app.Get("/", adaptor.HTTPHandler(handler(greet))) - - // http.HandlerFunc -> fiber.Handler - app.Get("/func", adaptor.HTTPHandlerFunc(greet)) - - // Listen on port 3000 - app.Listen(":3000") -} - -func handler(f http.HandlerFunc) http.Handler { - return http.HandlerFunc(f) -} - -func greet(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, "Hello World!") -} -``` - -## net/http middleware to Fiber - -```go -package main - -import ( - "log" - "net/http" - - "github.com/gofiber/adaptor/v2" - "github.com/gofiber/fiber/v3" -) - -func main() { - // New fiber app - app := fiber.New() - - // http middleware -> fiber.Handler - app.Use(adaptor.HTTPMiddleware(logMiddleware)) - - // Listen on port 3000 - app.Listen(":3000") -} - -func logMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - log.Println("log middleware") - next.ServeHTTP(w, r) - }) -} -``` - -## Fiber Handler to net/http - -```go -package main - -import ( - "net/http" - - "github.com/gofiber/adaptor/v2" - "github.com/gofiber/fiber/v3" -) - -func main() { - // fiber.Handler -> http.Handler - http.Handle("/", adaptor.FiberHandler(greet)) - - // fiber.Handler -> http.HandlerFunc - http.HandleFunc("/func", adaptor.FiberHandlerFunc(greet)) - - // Listen on port 3000 - http.ListenAndServe(":3000", nil) -} - -func greet(c fiber.Ctx) error { - return c.SendString("Hello World!") -} -``` - -## Fiber App to net/http - -```go -package main - -import ( - "github.com/gofiber/adaptor/v2" - "github.com/gofiber/fiber/v3" - "net/http" -) -func main() { - app := fiber.New() - - app.Get("/greet", greet) - - // Listen on port 3000 - http.ListenAndServe(":3000", adaptor.FiberApp(app)) -} - -func greet(c fiber.Ctx) error { - return c.SendString("Hello World!") -} -``` diff --git a/middleware/helmet/README.md b/middleware/helmet/README.md deleted file mode 100644 index e5724deef5..0000000000 --- a/middleware/helmet/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Helmet - -## Install - -```bash -go get -u github.com/gofiber/fiber/v3 -go get -u github.com/gofiber/middleware/helmet -``` - -## Example - -```go -package main - -import ( - "github.com/gofiber/fiber/v3" - "github.com/gofiber/fiber/helmet" -) - -func main() { - app := fiber.New() - - app.Use(helmet.New()) - - app.Get("/", func(c fiber.Ctx) error { - return c.SendString("Welcome!") - }) - - app.Listen(":3000") -} -``` - -## Test - -```bash -curl -I http://localhost:3000 -``` diff --git a/middleware/keyauth/README.md b/middleware/keyauth/README.md deleted file mode 100644 index 734ad40244..0000000000 --- a/middleware/keyauth/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Key Authentication - -## Install - -```bash -go get -u github.com/gofiber/fiber/v3 -go get -u github.com/gofiber/keyauth/v2 -``` - -## Example - -```go -package main - -import ( - "github.com/gofiber/fiber/v3" - "github.com/gofiber/fiber/middleware/keyauth" -) - -func main() { - app := fiber.New() - - app.Use(keyauth.New(keyauth.Config{ - KeyLookup: "cookie:access_token", - ContextKey: "my_token", - })) - - app.Get("/", func(c fiber.Ctx) error { - token := c.TokenFromContext(c) // "" is returned if not found - return c.SendString(token) - }) - - app.Listen(":3000") -} -``` - -## Test - -```bash -curl -v --cookie "access_token=hello_world" http://localhost:3000 -```