This file contains hidden or 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
package utils | |
import ( | |
"reflect" | |
"unsafe" | |
) | |
func BytesToString(b []byte) string { | |
return *(*string)(unsafe.Pointer(&b)) | |
} |
This file contains hidden or 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
func (s *server) respond(w http.ResponseWriter, r *http.Request, data interface{}, status int) { | |
w.WriteHeader(status) | |
if data != nil { | |
err := json.NewEncoder(w).Encode(data) | |
s.logf("json encode %s", err) | |
} | |
} | |
func (s *server) decode(w http.ResponseWriter, r *http.Request, v interface{}) error { | |
return json.NewDecoder(r.Body).Decode(v) |
This file contains hidden or 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
from gevent.wsgi import WSGIServer | |
from prometheus_client import multiprocess | |
from prometheus_client import generate_latest, CollectorRegistry, CONTENT_TYPE_LATEST | |
# Expose metrics. | |
def app(environ, start_response): | |
registry = CollectorRegistry() | |
multiprocess.MultiProcessCollector(registry) | |
data = generate_latest(registry) | |
status = '200 OK' |
OlderNewer