time curl -X POST --location "http://127.0.0.1:8080/url" \
-H "Content-Type: application/json" \
-d "{\"id\":\"1234567893\"}" \
-s -o /dev/null -w "%{time_starttransfer}\n"
Output will be like:
127618
time curl -X POST --location "http://127.0.0.1:8080/url" \
-H "Content-Type: application/json" \
-d "{\"id\":\"1234567893\"}" \
-s -o /dev/null -w "%{time_starttransfer}\n"
Output will be like:
127618
// IsIp checks that the given string is IPv4 or IPv6 address. | |
func IsIp(addr string) bool { | |
// IPv6 | |
if addr[0] == '[' { | |
return true | |
} | |
// domain can have digits, but it can't have ONLY digits | |
// So if all symbols are digits then this is an IPv4 address. We can check only first octet before dot . |
// EncodeToJsonAsciiText Fast json text value encode: escape " with \" and \ with \\ | |
// Any non printable or Unicode chars will be removed. | |
// Please note that value is not enclosed into double quotes. | |
func EncodeToJsonAsciiText(plain string) string { | |
plainLen := len(plain) | |
newSize := plainLen | |
for i := 0; i < plainLen; i++ { | |
c := plain[i] | |
if c < 32 || c > 127 { // skip non printable and unicode | |
newSize-- |
import ( | |
"github.com/prometheus/client_golang/prometheus" | |
"github.com/prometheus/client_golang/prometheus/promauto" | |
"google.golang.org/grpc/codes" | |
"google.golang.org/grpc/status" | |
"reflect" | |
"strconv" | |
) | |
// GrpcError The interface the same as internal type Error from grpc: internal/status/status.go |
package main | |
// parseIPv4 fast path clone of net.ParseIP that don't wrap IPv4 into IPv6 array | |
func parseIPv4(s string) []byte { | |
var p [4]byte | |
for i := 0; i < 4; i++ { | |
octet, pos := dtoi(s) | |
p[i] = octet | |
if i < 3 { | |
s = s[pos+1:] |
package bytesmap | |
var m = make(map[string]*string) | |
// this works faster | |
func GetOrDefaultInline(host []byte) *string { | |
hc, found := m[string(host)] | |
if !found { | |
m[string(host)] = nil | |
} |
package main | |
// UInt16Slice is a sorted slice | |
type UInt16Slice []uint16 | |
// BinSearch binary search over the sorted sclice | |
func (a UInt16Slice) BinSearch(key uint16) int { | |
low := 0 | |
high := len(a) - 1 | |
for low <= high { |
You'll need to instll OpenSSL and it will use about 1.3Mb. So check that it's enought of available space:
df -h | grep /overlay
Then install it:
opkg install openssl-util
It also will install libopenssl1.1
and libopenssl-conf
.