-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch add proxy.header.requestid configuration option for specifying header name for adding unique ID to each http request proxied by fabio. This header value can be logged in fabio access log and used for request processing tracking across different request handling applications.
- Loading branch information
1 parent
f6da7ac
commit 616b85b
Showing
8 changed files
with
130 additions
and
0 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
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
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,62 @@ | ||
package uuid | ||
|
||
// Fast UUID formatting adapted from | ||
// https://github.com/m4rw3r/uuid/blob/master/uuid.go | ||
|
||
// hexchar2byte contains the integer byte-value represented by a hexadecimal character, | ||
// 255 if it is an invalid character. | ||
var hexchar2byte = []byte{ | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, | ||
255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
} | ||
|
||
// halfbyte2hexchar contains an array of character values corresponding to | ||
// hexadecimal values for the position in the array, 0 to 15 (0x0-0xf, half-byte). | ||
var halfbyte2hexchar = []byte{ | ||
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, | ||
} | ||
|
||
// ToString formats raw UUID bytes as a standard UUID string | ||
func ToString(u [24]byte) string { | ||
/* It is a lot (~10x) faster to allocate a byte slice of specific size and | ||
then use a lookup table to write the characters to the byte-array and | ||
finally cast to string instead of using fmt.Sprintf() */ | ||
/* Slightly faster to not use make([]byte, 36), guessing either call | ||
overhead or slice-header overhead is the cause */ | ||
b := [36]byte{} | ||
|
||
for i, n := range []int{ | ||
0, 2, 4, 6, | ||
9, 11, | ||
14, 16, | ||
19, 21, | ||
24, 26, 28, 30, 32, 34, | ||
} { | ||
b[n] = halfbyte2hexchar[(u[i]>>4)&0x0f] | ||
b[n+1] = halfbyte2hexchar[u[i]&0x0f] | ||
} | ||
|
||
b[8] = '-' | ||
b[13] = '-' | ||
b[18] = '-' | ||
b[23] = '-' | ||
|
||
/* Oddly does not seem to cause a memory allocation, | ||
internal data-array is most likely just moved over | ||
to the string-header: */ | ||
return string(b[:]) | ||
} |
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,12 @@ | ||
package uuid | ||
|
||
import ( | ||
"github.com/rogpeppe/fastuuid" | ||
) | ||
|
||
var generator = fastuuid.MustNewGenerator() | ||
|
||
// NewUUID return UUID in string fromat | ||
func NewUUID() string { | ||
return ToString(generator.Next()) | ||
} |