httpserver

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: MIT Imports: 10 Imported by: 1

README

httpserver

httpserver for grpc/pb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextHandler

type ContextHandler func(context.Context, http.ResponseWriter, *http.Request)

type MethodDescription

type MethodDescription struct {
	MethodName string
	Handler    MethodHandler
}

type MethodHandler

type MethodHandler func(interface{}, context.Context, http.ResponseWriter, *http.Request)

MethodHandler handler format

type PBContextFunc

type PBContextFunc func(req *http.Request, ctx context.Context) context.Context
var PBContext PBContextFunc

type PBRequestFunc

type PBRequestFunc func(req *http.Request, in proto.Message) error
var PBRequest PBRequestFunc

type PBResponseFunc

type PBResponseFunc func(wr http.ResponseWriter, out proto.Message, err error)
var PBResponse PBResponseFunc

type RouteCfg

type RouteCfg struct {
	// contains filtered or unexported fields
}

type RouteOpt

type RouteOpt func(cf *RouteCfg)

func Handler

func Handler(h ContextHandler) RouteOpt
func Header(headers ...string) RouteOpt

func Host

func Host(host string) RouteOpt

func Method

func Method(methods ...string) RouteOpt

func Pattern

func Pattern(pattern string) RouteOpt

func Prefix

func Prefix(prefix string) RouteOpt

func Query

func Query(queries ...string) RouteOpt

func Schema

func Schema(schemas ...string) RouteOpt

type Server

type Server struct {
	http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...ServerOpt) *Server

func (*Server) RegisterService

func (srv *Server) RegisterService(sd *ServiceDescription, impl interface{}) error

RegistService

func (*Server) Route

func (srv *Server) Route(opts ...RouteOpt)

func (*Server) Serve

func (srv *Server) Serve(ctx context.Context) error

type ServerOpt

type ServerOpt func(*Server)

func IdleTimeout

func IdleTimeout(idle time.Duration) ServerOpt

func ListenAddress

func ListenAddress(addr string) ServerOpt

func ReadTimeout

func ReadTimeout(rd time.Duration) ServerOpt

func TLSFiles

func TLSFiles(certFile, keyFile string) ServerOpt

func WriteTimeout

func WriteTimeout(wr time.Duration) ServerOpt

type ServiceDescription

type ServiceDescription struct {
	PackageName  string
	ServiceName  string
	Implemention interface{}
	Methods      []MethodDescription
}

Directories

Path Synopsis
example
grpc command
simple command

Jump to

Keyboard shortcuts

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