generated from ZEISS/template-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
309c2de
commit 080682f
Showing
8 changed files
with
87 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1 @@ | ||
# :partying_face: Template Go | ||
|
||
> This is a GitHub Template Repository. You can use the green button to create a new repository based on this template. Read more about [GitHub Template Repositories](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template). | ||
## Get Started | ||
|
||
This template supports `Makefile` to run tooling. | ||
|
||
> `make` is choosen as it is available on most systems. | ||
```bash | ||
# show `help` | ||
make help | ||
``` | ||
|
||
Other available targets are | ||
|
||
* `build` | ||
* `fmt` | ||
* `lint` | ||
* `vet` | ||
* `generate` | ||
* `clean` | ||
|
||
The convention is to use `make` to run the build. | ||
|
||
Happy coding! | ||
# fiber-reload |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package example | ||
package reload | ||
|
||
//go:generate echo "Generating ..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 🚀 Fiber is an Express inspired web framework written in Go with 💖 | ||
// 📌 API Documentation: https://fiber.wiki | ||
// 📝 Github Repository: https://github.com/gofiber/fiber | ||
package reload | ||
|
||
import ( | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
// Config ... | ||
type Config struct { | ||
// Next defines a function to skip this middleware when returned true. | ||
Next func(c *fiber.Ctx) bool | ||
} | ||
|
||
// ConfigDefault is the default config. | ||
var ConfigDefault = Config{} | ||
|
||
// Reload is a middleware that enables a live reload of a site. | ||
func Authenticate(handler fiber.Handler, config ...Config) fiber.Handler { | ||
cfg := configDefault(config...) | ||
|
||
return func(c *fiber.Ctx) error { | ||
if cfg.Next != nil && cfg.Next(c) { | ||
return c.Next() | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
// Helper function to set default values | ||
func configDefault(config ...Config) Config { | ||
if len(config) < 1 { | ||
return ConfigDefault | ||
} | ||
|
||
// Override default config | ||
cfg := config[0] | ||
|
||
return cfg | ||
} |