From 2280ecb486295ab9f383ee6439a319fafaa26d36 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 26 Nov 2024 19:08:56 +0000 Subject: [PATCH] Add docs from https://github.com/gofiber/recipes/commit/1542b95 --- docs/recipes/autocert/README.md | 2 +- docs/recipes/dummyjson/README.md | 48 +++--- .../web/src/assets/fiber-logo.svg | 68 ++++----- docs/recipes/sqlc/README.md | 4 +- docs/recipes/swagger/README.md | 142 +++++++++--------- 5 files changed, 133 insertions(+), 131 deletions(-) diff --git a/docs/recipes/autocert/README.md b/docs/recipes/autocert/README.md index 9c04b9b946f..7ce97ecd835 100644 --- a/docs/recipes/autocert/README.md +++ b/docs/recipes/autocert/README.md @@ -1,6 +1,6 @@ --- title: Autocert -keywords: [autocert, tls, letsencrypt, ssl, https] +keywords: [autocert, tls, letsencrypt, ssl, https, certificate] --- # Autocert Example diff --git a/docs/recipes/dummyjson/README.md b/docs/recipes/dummyjson/README.md index c1c752ff41d..7506f82922c 100644 --- a/docs/recipes/dummyjson/README.md +++ b/docs/recipes/dummyjson/README.md @@ -1,27 +1,27 @@ ---- -title: Dummy JSON Proxy -keywords: [dummyjson, proxy, json, server] ---- - -# Simple Fiber Proxy Server +--- +title: Dummy JSON Proxy +keywords: [dummyjson, proxy, json, server] +--- + +# Simple Fiber Proxy Server [![Github](https://img.shields.io/static/v1?label=&message=Github&color=2ea44f&style=for-the-badge&logo=github)](https://github.com/gofiber/recipes/tree/master/dummyjson) [![StackBlitz](https://img.shields.io/static/v1?label=&message=StackBlitz&color=2ea44f&style=for-the-badge&logo=StackBlitz)](https://stackblitz.com/github/gofiber/recipes/tree/master/dummyjson) -This is a basic Go application using the Fiber framework to create a web server. The server listens on port 3000 and has a single route (`GET /`) that fetches data from an external URL (`https://dummyjson.com/products/1`) and forwards it to the client. - -### How to Run - -1. Clone the repository. -2. Navigate to the project directory. -3. Run `go run main.go`. -4. Visit `http://localhost:3000/` in a web browser or use a tool like `curl` to test it. - -### What It Does - -- Fetches data from an external service, in this case `DummyJson.com` -- Forwards the fetched data or an error message to the client. - -### Error Handling - -- Returns a 500 Internal Server Error if any issue occurs during the fetch. -- Returns the same status code as the external service if it's not a 200 OK. +This is a basic Go application using the Fiber framework to create a web server. The server listens on port 3000 and has a single route (`GET /`) that fetches data from an external URL (`https://dummyjson.com/products/1`) and forwards it to the client. + +### How to Run + +1. Clone the repository. +2. Navigate to the project directory. +3. Run `go run main.go`. +4. Visit `http://localhost:3000/` in a web browser or use a tool like `curl` to test it. + +### What It Does + +- Fetches data from an external service, in this case `DummyJson.com` +- Forwards the fetched data or an error message to the client. + +### Error Handling + +- Returns a 500 Internal Server Error if any issue occurs during the fetch. +- Returns the same status code as the external service if it's not a 200 OK. diff --git a/docs/recipes/react-router/web/src/assets/fiber-logo.svg b/docs/recipes/react-router/web/src/assets/fiber-logo.svg index f52e60df8d8..d1895249397 100644 --- a/docs/recipes/react-router/web/src/assets/fiber-logo.svg +++ b/docs/recipes/react-router/web/src/assets/fiber-logo.svg @@ -1,34 +1,34 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/docs/recipes/sqlc/README.md b/docs/recipes/sqlc/README.md index c3e2fab9350..7bb52bbf407 100644 --- a/docs/recipes/sqlc/README.md +++ b/docs/recipes/sqlc/README.md @@ -9,8 +9,10 @@ keywords: [database, sqlc, postgresql] > #### 🎯 [fiber](https://github.com/gofiber/fiber) + [sqlc](https://github.com/sqlc-dev/sqlc) Example -## 👀 Usage +## Usage + #### 1. Run Postgres + ```bash $ docker compose build ``` diff --git a/docs/recipes/swagger/README.md b/docs/recipes/swagger/README.md index 995fe0ab3a0..983c7711fbf 100644 --- a/docs/recipes/swagger/README.md +++ b/docs/recipes/swagger/README.md @@ -1,74 +1,74 @@ ---- -title: Swagger -keywords: [swagger, api, documentation, contrib] ---- - -# Swagger API Documentation +--- +title: Swagger +keywords: [swagger, api, documentation, contrib] +--- + +# Swagger API Documentation [![Github](https://img.shields.io/static/v1?label=&message=Github&color=2ea44f&style=for-the-badge&logo=github)](https://github.com/gofiber/recipes/tree/master/swagger) [![StackBlitz](https://img.shields.io/static/v1?label=&message=StackBlitz&color=2ea44f&style=for-the-badge&logo=StackBlitz)](https://stackblitz.com/github/gofiber/recipes/tree/master/swagger) -This project demonstrates how to integrate Swagger for API documentation in a Go application. - -## Prerequisites - -Ensure you have the following installed: - -- Golang -- [Swag](https://github.com/swaggo/swag) for generating Swagger docs - -## Setup - -1. Clone the repository: - ```sh - git clone https://github.com/gofiber/recipes.git - cd recipes/swagger - ``` - -2. Install dependencies: - ```sh - go get -u github.com/swaggo/swag/cmd/swag - go get -u github.com/swaggo/gin-swagger - go get -u github.com/swaggo/files - ``` - -## Generating Swagger Docs - -1. Generate the Swagger documentation: - ```sh - swag init - ``` - -## Running the Application - -1. Start the application: - ```sh - go run main.go - ``` - -2. Access the Swagger UI: - Open your browser and navigate to `http://localhost:8080/swagger/index.html` - -## Example - -Here is an example of how to document an API endpoint using Swag: - -```go -// @Summary Show an account -// @Description get string by ID -// @ID get-string-by-int -// @Accept json -// @Produce json -// @Param id path int true "Account ID" -// @Success 200 {object} model.Account -// @Failure 400 {object} http.Response -// @Failure 404 {object} http.Response -// @Router /accounts/{id} [get] -func GetAccount(c *gin.Context) { - // Your code here -} -``` - -## References - -- [Swag Documentation](https://github.com/swaggo/swag) -- [Gin Swagger Middleware](https://github.com/swaggo/gin-swagger) +This project demonstrates how to integrate Swagger for API documentation in a Go application. + +## Prerequisites + +Ensure you have the following installed: + +- Golang +- [Swag](https://github.com/swaggo/swag) for generating Swagger docs + +## Setup + +1. Clone the repository: + ```sh + git clone https://github.com/gofiber/recipes.git + cd recipes/swagger + ``` + +2. Install dependencies: + ```sh + go get -u github.com/swaggo/swag/cmd/swag + go get -u github.com/swaggo/gin-swagger + go get -u github.com/swaggo/files + ``` + +## Generating Swagger Docs + +1. Generate the Swagger documentation: + ```sh + swag init + ``` + +## Running the Application + +1. Start the application: + ```sh + go run main.go + ``` + +2. Access the Swagger UI: + Open your browser and navigate to `http://localhost:8080/swagger/index.html` + +## Example + +Here is an example of how to document an API endpoint using Swag: + +```go +// @Summary Show an account +// @Description get string by ID +// @ID get-string-by-int +// @Accept json +// @Produce json +// @Param id path int true "Account ID" +// @Success 200 {object} model.Account +// @Failure 400 {object} http.Response +// @Failure 404 {object} http.Response +// @Router /accounts/{id} [get] +func GetAccount(c *gin.Context) { + // Your code here +} +``` + +## References + +- [Swag Documentation](https://github.com/swaggo/swag) +- [Gin Swagger Middleware](https://github.com/swaggo/gin-swagger)