mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-31 11:52:41 +00:00
📝 docs: gofmt & add missing copyright texts (#2013)
This commit is contained in:
parent
e8a2ba363c
commit
6669ec4486
5
app.go
5
app.go
@ -63,6 +63,7 @@ type Storage interface {
|
||||
|
||||
// ErrorHandler defines a function that will process all errors
|
||||
// returned from any handlers in the stack
|
||||
//
|
||||
// cfg := fiber.Config{}
|
||||
// cfg.ErrorHandler = func(c *Ctx, err error) error {
|
||||
// code := StatusInternalServerError
|
||||
@ -438,8 +439,11 @@ var DefaultErrorHandler = func(c *Ctx, err error) error {
|
||||
}
|
||||
|
||||
// New creates a new Fiber named instance.
|
||||
//
|
||||
// app := fiber.New()
|
||||
//
|
||||
// You can pass optional configuration options by passing a Config struct:
|
||||
//
|
||||
// app := fiber.New(fiber.Config{
|
||||
// Prefork: true,
|
||||
// ServerHeader: "Fiber",
|
||||
@ -710,6 +714,7 @@ func (app *App) All(path string, handlers ...Handler) Router {
|
||||
}
|
||||
|
||||
// Group is used for Routes with common prefix to define a new sub-router with optional middleware.
|
||||
//
|
||||
// api := app.Group("/api")
|
||||
// api.Get("/users", handler)
|
||||
func (app *App) Group(prefix string, handlers ...Handler) Router {
|
||||
|
@ -566,6 +566,7 @@ func (a *Agent) SendFile(filename string, fieldname ...string) *Agent {
|
||||
// SendFiles reads files and appends them to multipart form request.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// SendFile("/path/to/file1", "fieldname1", "/path/to/file2")
|
||||
func (a *Agent) SendFiles(filenamesAndFieldnames ...string) *Agent {
|
||||
pairs := len(filenamesAndFieldnames)
|
||||
|
1
group.go
1
group.go
@ -171,6 +171,7 @@ func (grp *Group) All(path string, handlers ...Handler) Router {
|
||||
}
|
||||
|
||||
// Group is used for Routes with common prefix to define a new sub-router with optional middleware.
|
||||
//
|
||||
// api := app.Group("/api")
|
||||
// api.Get("/users", handler)
|
||||
func (grp *Group) Group(prefix string, handlers ...Handler) Router {
|
||||
|
@ -65,9 +65,9 @@ func ExecuteFunc(template, startTag, endTag string, w io.Writer, f TagFunc) (int
|
||||
// values from the map m and writes the result to the given writer w.
|
||||
//
|
||||
// Substitution map m may contain values with the following types:
|
||||
// * []byte - the fastest value type
|
||||
// * string - convenient value type
|
||||
// * TagFunc - flexible value type
|
||||
// - []byte - the fastest value type
|
||||
// - string - convenient value type
|
||||
// - TagFunc - flexible value type
|
||||
//
|
||||
// Returns the number of bytes written to w.
|
||||
//
|
||||
@ -81,9 +81,9 @@ func Execute(template, startTag, endTag string, w io.Writer, m map[string]interf
|
||||
// This can be used as a drop-in replacement for strings.Replacer
|
||||
//
|
||||
// Substitution map m may contain values with the following types:
|
||||
// * []byte - the fastest value type
|
||||
// * string - convenient value type
|
||||
// * TagFunc - flexible value type
|
||||
// - []byte - the fastest value type
|
||||
// - string - convenient value type
|
||||
// - TagFunc - flexible value type
|
||||
//
|
||||
// Returns the number of bytes written to w.
|
||||
//
|
||||
@ -135,9 +135,9 @@ var byteBufferPool bytebufferpool.Pool
|
||||
// values from the map m and returns the result.
|
||||
//
|
||||
// Substitution map m may contain values with the following types:
|
||||
// * []byte - the fastest value type
|
||||
// * string - convenient value type
|
||||
// * TagFunc - flexible value type
|
||||
// - []byte - the fastest value type
|
||||
// - string - convenient value type
|
||||
// - TagFunc - flexible value type
|
||||
//
|
||||
// This function is optimized for constantly changing templates.
|
||||
// Use Template.ExecuteString for frozen templates.
|
||||
@ -149,9 +149,9 @@ func ExecuteString(template, startTag, endTag string, m map[string]interface{})
|
||||
// This can be used as a drop-in replacement for strings.Replacer
|
||||
//
|
||||
// Substitution map m may contain values with the following types:
|
||||
// * []byte - the fastest value type
|
||||
// * string - convenient value type
|
||||
// * TagFunc - flexible value type
|
||||
// - []byte - the fastest value type
|
||||
// - string - convenient value type
|
||||
// - TagFunc - flexible value type
|
||||
//
|
||||
// This function is optimized for constantly changing templates.
|
||||
// Use Template.ExecuteStringStd for frozen templates.
|
||||
@ -305,9 +305,9 @@ func (t *Template) ExecuteFunc(w io.Writer, f TagFunc) (int64, error) {
|
||||
// values from the map m and writes the result to the given writer w.
|
||||
//
|
||||
// Substitution map m may contain values with the following types:
|
||||
// * []byte - the fastest value type
|
||||
// * string - convenient value type
|
||||
// * TagFunc - flexible value type
|
||||
// - []byte - the fastest value type
|
||||
// - string - convenient value type
|
||||
// - TagFunc - flexible value type
|
||||
//
|
||||
// Returns the number of bytes written to w.
|
||||
func (t *Template) Execute(w io.Writer, m map[string]interface{}) (int64, error) {
|
||||
@ -318,9 +318,9 @@ func (t *Template) Execute(w io.Writer, m map[string]interface{}) (int64, error)
|
||||
// This can be used as a drop-in replacement for strings.Replacer
|
||||
//
|
||||
// Substitution map m may contain values with the following types:
|
||||
// * []byte - the fastest value type
|
||||
// * string - convenient value type
|
||||
// * TagFunc - flexible value type
|
||||
// - []byte - the fastest value type
|
||||
// - string - convenient value type
|
||||
// - TagFunc - flexible value type
|
||||
//
|
||||
// Returns the number of bytes written to w.
|
||||
func (t *Template) ExecuteStd(w io.Writer, m map[string]interface{}) (int64, error) {
|
||||
@ -366,9 +366,9 @@ func (t *Template) ExecuteFuncStringWithErr(f TagFunc) (string, error) {
|
||||
// values from the map m and returns the result.
|
||||
//
|
||||
// Substitution map m may contain values with the following types:
|
||||
// * []byte - the fastest value type
|
||||
// * string - convenient value type
|
||||
// * TagFunc - flexible value type
|
||||
// - []byte - the fastest value type
|
||||
// - string - convenient value type
|
||||
// - TagFunc - flexible value type
|
||||
//
|
||||
// This function is optimized for frozen templates.
|
||||
// Use ExecuteString for constantly changing templates.
|
||||
@ -380,9 +380,9 @@ func (t *Template) ExecuteString(m map[string]interface{}) string {
|
||||
// This can be used as a drop-in replacement for strings.Replacer
|
||||
//
|
||||
// Substitution map m may contain values with the following types:
|
||||
// * []byte - the fastest value type
|
||||
// * string - convenient value type
|
||||
// * TagFunc - flexible value type
|
||||
// - []byte - the fastest value type
|
||||
// - string - convenient value type
|
||||
// - TagFunc - flexible value type
|
||||
//
|
||||
// This function is optimized for frozen templates.
|
||||
// Use ExecuteStringStd for constantly changing templates.
|
||||
|
@ -31,7 +31,6 @@
|
||||
// returns a slice pointing to the next `n` bytes of the writer, and increments
|
||||
// the write position by the length of the returned slice. This allows users
|
||||
// to write directly to the end of the buffer.
|
||||
//
|
||||
package fwd
|
||||
|
||||
import "io"
|
||||
|
@ -114,6 +114,7 @@ func ReadLines(filename string) ([]string, error) {
|
||||
// ReadLines reads contents from file and splits them by new line.
|
||||
// The offset tells at which line number to start.
|
||||
// The count determines the number of lines to read (starting from offset):
|
||||
//
|
||||
// n >= 0: at most n lines
|
||||
// n < 0: whole file
|
||||
func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
|
||||
|
@ -211,8 +211,11 @@ func WMIQueryWithContext(ctx context.Context, query string, dst interface{}, con
|
||||
}
|
||||
|
||||
// Convert paths using native DOS format like:
|
||||
//
|
||||
// "\Device\HarddiskVolume1\Windows\systemew\file.txt"
|
||||
//
|
||||
// into:
|
||||
//
|
||||
// "C:\Windows\systemew\file.txt"
|
||||
func ConvertDOSPath(p string) string {
|
||||
rawDrive := strings.Join(strings.Split(p, `\`)[:3], `\`)
|
||||
|
@ -161,6 +161,7 @@ var netProtocols = []string{
|
||||
// If protocols is empty then all protocols are returned, otherwise
|
||||
// just the protocols in the list are returned.
|
||||
// Available protocols:
|
||||
//
|
||||
// ip,icmp,icmpmsg,tcp,udp,udplite
|
||||
func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
|
||||
return ProtoCountersWithContext(context.Background(), protocols)
|
||||
|
@ -208,6 +208,7 @@ func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename stri
|
||||
|
||||
// Return a list of network connections
|
||||
// Available kind:
|
||||
//
|
||||
// reference to netConnectionKindMap
|
||||
func Connections(kind string) ([]ConnectionStat, error) {
|
||||
return ConnectionsWithContext(context.Background(), kind)
|
||||
|
@ -42,6 +42,7 @@ func IsTerminal(fd uintptr) bool {
|
||||
|
||||
// Check pipe name is used for cygwin/msys2 pty.
|
||||
// Cygwin/MSYS2 PTY has a name like:
|
||||
//
|
||||
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
|
||||
func isCygwinPipeName(name string) bool {
|
||||
token := strings.Split(name, "-")
|
||||
|
@ -12,8 +12,11 @@
|
||||
//
|
||||
// Once a type has satisfied the `Encodable` and `Decodable` interfaces,
|
||||
// it can be written and read from arbitrary `io.Writer`s and `io.Reader`s using
|
||||
//
|
||||
// msgp.Encode(io.Writer, msgp.Encodable)
|
||||
//
|
||||
// and
|
||||
//
|
||||
// msgp.Decode(io.Reader, msgp.Decodable)
|
||||
//
|
||||
// There are also methods for converting MessagePack to JSON without
|
||||
|
@ -4,7 +4,6 @@ package msgp
|
||||
// plus type information. gives us
|
||||
// constant-time type information
|
||||
// for traversing composite objects.
|
||||
//
|
||||
var sizes = [256]bytespec{
|
||||
mnil: {size: 1, extra: constsize, typ: NilType},
|
||||
mfalse: {size: 1, extra: constsize, typ: BoolType},
|
||||
|
@ -70,7 +70,6 @@ func Resumable(e error) bool {
|
||||
//
|
||||
// ErrShortBytes is not wrapped with any context due to backward compatibility
|
||||
// issues with the public API.
|
||||
//
|
||||
func WrapError(err error, ctx ...interface{}) error {
|
||||
switch e := err.(type) {
|
||||
case errShort:
|
||||
|
@ -21,7 +21,6 @@ import (
|
||||
// is only efficient for large files; small
|
||||
// files are best read and written using
|
||||
// the ordinary streaming interfaces.
|
||||
//
|
||||
func ReadFile(dst Unmarshaler, file *os.File) error {
|
||||
stat, err := file.Stat()
|
||||
if err != nil {
|
||||
|
@ -896,7 +896,7 @@ func ReadStringBytes(b []byte) (string, []byte, error) {
|
||||
// into a slice of bytes. 'v' is the value of
|
||||
// the 'str' object, which may reside in memory
|
||||
// pointed to by 'scratch.' 'o' is the remaining bytes
|
||||
// in 'b.''
|
||||
// in 'b.”
|
||||
// Possible errors:
|
||||
// - ErrShortBytes (b not long enough)
|
||||
// - TypeError{} (not 'str' type)
|
||||
|
@ -60,14 +60,14 @@ certain fields, use a dash for the name and it will be ignored:
|
||||
|
||||
The supported field types in the destination struct are:
|
||||
|
||||
* bool
|
||||
* float variants (float32, float64)
|
||||
* int variants (int, int8, int16, int32, int64)
|
||||
* string
|
||||
* uint variants (uint, uint8, uint16, uint32, uint64)
|
||||
* struct
|
||||
* a pointer to one of the above types
|
||||
* a slice or a pointer to a slice of one of the above types
|
||||
- bool
|
||||
- float variants (float32, float64)
|
||||
- int variants (int, int8, int16, int32, int64)
|
||||
- string
|
||||
- uint variants (uint, uint8, uint16, uint32, uint64)
|
||||
- struct
|
||||
- a pointer to one of the above types
|
||||
- a slice or a pointer to a slice of one of the above types
|
||||
|
||||
Non-supported types are simply ignored, however custom types can be registered
|
||||
to be converted.
|
||||
|
@ -1,3 +1,4 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package wmi
|
||||
|
@ -1,3 +1,4 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
/*
|
||||
@ -20,7 +21,6 @@ Example code to print names of running processes:
|
||||
println(i, v.Name)
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
package wmi
|
||||
|
||||
|
@ -75,6 +75,7 @@ func (app *App) Listen(addr string) error {
|
||||
|
||||
// ListenTLS serves HTTPS requests from the given addr.
|
||||
// certFile and keyFile are the paths to TLS certificate and key file:
|
||||
//
|
||||
// app.ListenTLS(":8080", "./cert.pem", "./cert.key")
|
||||
func (app *App) ListenTLS(addr, certFile, keyFile string) error {
|
||||
// Check for valid cert/key path
|
||||
@ -116,6 +117,7 @@ func (app *App) ListenTLS(addr, certFile, keyFile string) error {
|
||||
|
||||
// ListenMutualTLS serves HTTPS requests from the given addr.
|
||||
// certFile, keyFile and clientCertFile are the paths to TLS certificate and key file:
|
||||
//
|
||||
// app.ListenMutualTLS(":8080", "./cert.pem", "./cert.key", "./client.pem")
|
||||
func (app *App) ListenMutualTLS(addr, certFile, keyFile, clientCertFile string) error {
|
||||
// Check for valid cert/key path
|
||||
|
4
middleware/cache/manager_msgp.go
vendored
4
middleware/cache/manager_msgp.go
vendored
@ -58,7 +58,7 @@ func (z *item) DecodeMsg(dc *msgp.Reader) (err error) {
|
||||
if z.headers == nil && zcmr > 0 {
|
||||
z.headers = make(map[string][]byte, zcmr)
|
||||
} else if len(z.headers) > 0 {
|
||||
for key, _ := range z.headers {
|
||||
for key := range z.headers {
|
||||
delete(z.headers, key)
|
||||
}
|
||||
}
|
||||
@ -252,7 +252,7 @@ func (z *item) UnmarshalMsg(bts []byte) (o []byte, err error) {
|
||||
if z.headers == nil && zwht > 0 {
|
||||
z.headers = make(map[string][]byte, zwht)
|
||||
} else if len(z.headers) > 0 {
|
||||
for key, _ := range z.headers {
|
||||
for key := range z.headers {
|
||||
delete(z.headers, key)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user