webservice

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

README

webservice

Golang Microservice helper based on gorilla/mux

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowAllCorsMiddleware

func AllowAllCorsMiddleware(h http.Handler) http.Handler

AllowAllCorsMiddleware returns middleware function that can be used in router.Use()

Types

type AppHandler

type AppHandler func(w http.ResponseWriter, r *http.Request) error

AppHandler is handler that take care of content type and error handling

func (AppHandler) ServeHTTP

func (ah AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Satisfies the http.Handler interface

type AppHandlerWithUserID

type AppHandlerWithUserID func(userID string, w http.ResponseWriter, r *http.Request) error

AppHandlerWithUserID is handler that take care of userID, content type and error handling

func (AppHandlerWithUserID) ServeHTTP

func (ah AppHandlerWithUserID) ServeHTTP(w http.ResponseWriter, r *http.Request)

Satisfies the http.Handler interface

type ConfigureRouterHandler added in v0.4.0

type ConfigureRouterHandler interface {
	ConfigureRouter(router *mux.Router) (handler http.Handler, err error)
}

ConfigureRouterHandler ...

type GelfFormatter

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

GelfFormatter ...

func (*GelfFormatter) Format

func (f *GelfFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format formats the log entry to GELF JSON

type ServerStatus

type ServerStatus struct {
	Running   bool   `json:"running"`
	Process   string `json:"process"`
	Pid       int    `json:"pid"`
	StripPath string `json:"strip_path"`
}

ServerStatus return actual state and process data so you can test with url/state the correct installation of microservice

func NewServerStatus

func NewServerStatus() *ServerStatus

NewServerStatus create default service status

type SimpleService

type SimpleService interface {
	Start() (err error)                                                                           // Start service
	SetTimeouts(writeTimeout time.Duration, readTimeout time.Duration, idleTimeout time.Duration) // set timeouts. 0 will use default values. It must be called before start
}

SimpleService ...

func NewSimpleService

func NewSimpleService(obj SimpleServiceObject) SimpleService

NewSimpleService creates new simple service object

type SimpleServiceBase

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

SimpleServiceBase ...

func (*SimpleServiceBase) SetTimeouts added in v0.2.1

func (s *SimpleServiceBase) SetTimeouts(writeTimeout time.Duration, readTimeout time.Duration, idleTimeout time.Duration)

func (*SimpleServiceBase) Start

func (s *SimpleServiceBase) Start() (err error)

Start starts service

type SimpleServiceBeforeEnd added in v0.2.2

type SimpleServiceBeforeEnd interface {
	BeforeEnd()
}

SimpleServiceBeforeEnd ...

type SimpleServiceBeforeStart

type SimpleServiceBeforeStart interface {
	BeforeStart() (err error)
}

SimpleServiceBeforeStart ...

type SimpleServiceGetHTTPHandlerObsolete added in v0.4.0

type SimpleServiceGetHTTPHandlerObsolete interface {
	GetHTTPHandler() (handler http.Handler, err error)
}

SimpleServiceGetHTTPHandlerObsolete ...

type SimpleServiceGetStatusHandler added in v0.4.0

type SimpleServiceGetStatusHandler interface {
	GetServerStatus() (status interface{})
}

SimpleServiceGetStatusHandler ...

type SimpleServiceObject

type SimpleServiceObject interface {
}

SimpleServiceObject ...

type SimpleServicePreparePFlags

type SimpleServicePreparePFlags interface {
	PreparePFlags() (err error)
}

SimpleServicePreparePFlags ...

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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