corekit

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIHandler

type APIHandler func(req *http.Request) (interface{}, error)

API Handler

type Option

type Option func(o *Options)

func Dependency added in v1.0.1

func Dependency(name string, f func() error) Option

func DependencyInfo

func DependencyInfo(name string, f func() interface{}) Option

func Https

func Https(certFile, keyFile string) Option

func Logger

func Logger(l func(format string, args ...interface{})) Option

func Name

func Name(n string) Option

func Param

func Param(name, val string) Option

func Port

func Port(port int) Option

func UseServeMux

func UseServeMux(mux ServeMux) Option

func Version

func Version(v string) Option

type Options

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

type Response added in v1.1.0

type Response struct {
	StatusCode int
	Header     http.Header
	Payload    interface{}
}

Response is structure for HTTP response

func Created added in v1.1.0

func Created() Response

Created return new instance of HTTP response with status code Created

func NoContent added in v1.1.0

func NoContent() Response

NoContent return new instance of HTTP response with status code NoContent

func OK added in v1.1.0

func OK(payload interface{}) Response

OK return new instance of HTTP response with status code OK

type ServeMux

type ServeMux interface {
	Add(meth string, pat string, h http.Handler)
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

type Service

type Service interface {
	Get(path string, handler APIHandler)
	Post(path string, handler APIHandler)
	Put(path string, handler APIHandler)
	Del(path string, handler APIHandler)
	Stream(path string, handler StreamAPIHandler)

	Run()
}

func NewService

func NewService(opts ...Option) Service

type StreamAPIHandler

type StreamAPIHandler func(req *http.Request) (receiver chan []byte, cancel chan struct{}, err error)

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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