[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
/ negroni-server-status Public archive

[deprecated] A negroni middleware which serves server-status endpoint

License

Notifications You must be signed in to change notification settings

astj/negroni-server-status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

negroni-server-status

A negroni middleware to monitor HTTP request stats like Plack::Middleware::ServerStatus::Lite

deprecation notice

Currently I don't use this middleware anymore. It may still work, but may not anymore.

Current Limitations

Comparing to original Plack::Middleware::ServerStatus::Lite, this middleware has following limitations.

  • IdleWorker value is always empty
    • net/http server does not limit total numbers of workers, so this field is meaningless
  • Always returns response in JSON formats
  • Response does not contain individual processing requests (stats field)
  • Access Restriction is not implemented

The lattar three are not implemented because I don't need them currently, but patches are welcome.

Usage

See example/main.go.

package main

import (
	"fmt"
	"net/http"

	nss "github.com/astj/negroni-server-status"
	"github.com/urfave/negroni"
)

func main() {
	mux := http.NewServeMux()

	mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
		fmt.Fprint(w, "This is from internal")
	})

	n := negroni.New()

	n.Use(nss.NewMiddleware("/server-status"))

	n.UseHandler(mux)

	n.Run(":3000")
}

In this case, a response from http://localhost:3000/server-status is somewhat like this:

{"Uptime":"60","TotalAccesses":"67","TotalKbytes":"1","BusyWorkers":"1","IdleWorkers":"","stats":[]}
key type of value meaning
Uptime string Elapsed seconds from this server starts
TotalAccess string Number of requests processed by this server
TotalKbytes string Sum of response body size processed by this server, in KB units
BusyWorkers string Number of currently processing requests
IdleWorkers string Just empty. Available for compatibility with original Plack middleware
stats [] Should be information about current connections (not implemented)

License

MIT

Author

@astj (Asato Wakisaka)

About

[deprecated] A negroni middleware which serves server-status endpoint

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages