svc2handler

package module
Version: v0.0.0-...-01f53ac Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: Apache-2.0 Imports: 3 Imported by: 1

README

Svc2Handler

auto convert your go func or service to http handler

focus on service not server

Benchmark

BenchmarkRun-20                       	 7398498	       161 ns/op	       0 B/op	       0 allocs/op
BenchmarkRunContext-20                	 1878054	       635 ns/op	       0 B/op	       0 allocs/op
BenchmarkRunMap-20                    	 2806616	       428 ns/op	      64 B/op	       3 allocs/op
BenchmarkRunStruct-20                 	 3117616	       386 ns/op	      56 B/op	       3 allocs/op
BenchmarkRunMultiParam-20             	 2031732	       591 ns/op	     104 B/op	       4 allocs/op
BenchmarkRunStructWithCtx-20          	 1000000	      1045 ns/op	      88 B/op	       3 allocs/op
BenchmarkRunMultiParamContext-20      	 1000000	      1172 ns/op	     144 B/op	       4 allocs/op
BenchmarkRunMultiParam2-20            	 1252812	       954 ns/op	     256 B/op	       7 allocs/op
BenchmarkRunMultiStruct5WithCtx-20    	  812223	      1486 ns/op	     288 B/op	       7 allocs/op
BenchmarkRunDef-20                    	261235088	         4.52 ns/op	       0 B/op	       0 allocs/op

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleSvcWithIO

func HandleSvcWithIO(io IOController, svc interface{}) http.HandlerFunc

Types

type IOController

type IOController interface {
	Response(w http.ResponseWriter, ret interface{}, err error)

	ParamHandler(w http.ResponseWriter, r *http.Request, params []interface{}) (ok bool)
}

type SvcHandler

type SvcHandler func(svc interface{}) http.HandlerFunc

func CreateSvcHandler

func CreateSvcHandler(svr IOController) SvcHandler

func (SvcHandler) Handle

func (w SvcHandler) Handle(svc interface{}) http.HandlerFunc

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL