goserver

package module
v2.1.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2017 License: MIT Imports: 5 Imported by: 2

README

Vardius - goserver

Build Status Coverage Status

Go Server/API micro framwework, HTTP request router, multiplexer, mux.

Benchmarks

The output

BenchmarkStrict1-4             	 3000000	       525 ns/op

means that the loop ran 3000000 times at a speed of 525 ns per loop. What gives around 3508772 req/sec ! Each benchmark name BenchmarkStrict5-4 means that test used a strict or regexp route path for each node with a nested level 5. Where 4 stands for CPU number.

The benchmarks are located in file benchmark_test.go.

$ go test -bench=. -cpu=4
BenchmarkStrict1-4             	 3000000	       525 ns/op
BenchmarkStrict2-4             	 2000000	       583 ns/op
BenchmarkStrict3-4             	 2000000	       631 ns/op
BenchmarkStrict5-4             	 2000000	       749 ns/op
BenchmarkStrict10-4            	 2000000	       995 ns/op
BenchmarkStrict100-4           	  300000	      5525 ns/op
BenchmarkStrictParallel1-4     	 5000000	       285 ns/op
BenchmarkStrictParallel2-4     	10000000	       270 ns/op
BenchmarkStrictParallel3-4     	 5000000	       306 ns/op
BenchmarkStrictParallel5-4     	 5000000	       298 ns/op
BenchmarkStrictParallel10-4    	 3000000	       451 ns/op
BenchmarkStrictParallel100-4   	 1000000	      1913 ns/op
BenchmarkRegexp1-4             	 1000000	      1121 ns/op
BenchmarkRegexp2-4             	 1000000	      1802 ns/op
BenchmarkRegexp3-4             	 1000000	      2200 ns/op
BenchmarkRegexp5-4             	  500000	      3218 ns/op
BenchmarkRegexp10-4            	  300000	      5993 ns/op
BenchmarkRegexp100-4           	   30000	     51510 ns/op
BenchmarkRegexpParallel1-4     	 2000000	       697 ns/op
BenchmarkRegexpParallel2-4     	 1000000	      1003 ns/op
BenchmarkRegexpParallel3-4     	 1000000	      1413 ns/op
BenchmarkRegexpParallel5-4     	 1000000	      1613 ns/op
BenchmarkRegexpParallel10-4    	  500000	      2856 ns/op
BenchmarkRegexpParallel100-4   	  100000	     22202 ns/op

ABOUT

Contributors:

Want to contribute ? Feel free to send pull requests!

Have problems, bugs, feature ideas? We are using the github issue tracker to manage them.

HOW TO USE

GoDoc

Usage

License

This package is released under the MIT license. See the complete license in the package:

LICENSE

Documentation

Index

Constants

View Source
const (
	GET     = "GET"
	POST    = "POST"
	PUT     = "PUT"
	DELETE  = "DELETE"
	PATCH   = "PATCH"
	OPTIONS = "OPTIONS"
)

HTTP methods constants

Variables

This section is empty.

Functions

This section is empty.

Types

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type Param

type Param struct {
	Key   string
	Value string
}

Param object to hold request parameter

type Params

type Params []Param

Params slice returned from request context

func ParamsFromContext

func ParamsFromContext(ctx context.Context) (Params, bool)

func (Params) Value

func (p Params) Value(key string) string

Value of the request parameter by name

type Server

type Server interface {
	POST(path string, f http.HandlerFunc)
	GET(path string, f http.HandlerFunc)
	PUT(path string, f http.HandlerFunc)
	DELETE(path string, f http.HandlerFunc)
	PATCH(path string, f http.HandlerFunc)
	OPTIONS(path string, f http.HandlerFunc)
	USE(method, path string, fs ...MiddlewareFunc)
	ServeHTTP(http.ResponseWriter, *http.Request)
	ServeFiles(path string, strip bool)
	NotFound(http.Handler)
	NotAllowed(http.Handler)
}

func New

func New(fs ...MiddlewareFunc) Server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL