restapi

package module
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 21 Imported by: 4

README

Common Libraries used by other projects

Build Release Security

This project is used as a common set of libraries to use on my other projects. this might not be as useful without them but feel free to use it as inspiration

Documentation

Index

Constants

View Source
const (
	REQUEST_ID_KEY = "requestId"
)

Variables

This section is empty.

Functions

func CorrelationMiddlewareAdapter

func CorrelationMiddlewareAdapter(logHealthCheck bool) controllers.Adapter

func GetRequestId added in v0.0.12

func GetRequestId(r *http.Request) string

func JsonContentMiddlewareAdapter

func JsonContentMiddlewareAdapter() controllers.Adapter

func LoggerMiddlewareAdapter

func LoggerMiddlewareAdapter(logHealthCheck bool) controllers.Adapter

func RequestIdMiddlewareAdapter added in v0.0.12

func RequestIdMiddlewareAdapter() controllers.Adapter

Types

type DefaultHomepage

type DefaultHomepage struct {
	CorrelationID string `json:"id" bson:"_id" yaml:"id"`
	Timestamp     string `json:"timestamp" bson:"timestamp" yaml:"timestamp"`
	Message       string `json:"message" bson:"message" yaml:"message"`
}

type HttpListener

type HttpListener struct {
	Router          *mux.Router
	Context         *execution_context.Context
	Logger          *log.LoggerService
	Options         *HttpListenerOptions
	Controllers     []controllers.Controller
	DefaultAdapters []controllers.Adapter
	Servers         []*http.Server
	// contains filtered or unexported fields
}

HttpListener HttpListener structure

func GetHttpListener

func GetHttpListener() *HttpListener

func NewHttpListener

func NewHttpListener() *HttpListener

NewHttpListener Creates a new controller

func (*HttpListener) AddController

func (l *HttpListener) AddController(c controllers.Controller, path string, methods ...string)

func (*HttpListener) AddDefaultHomepage

func (l *HttpListener) AddDefaultHomepage() *HttpListener

func (*HttpListener) AddHealthCheck

func (l *HttpListener) AddHealthCheck() *HttpListener

func (*HttpListener) AddJsonContent

func (l *HttpListener) AddJsonContent() *HttpListener

func (*HttpListener) AddLogger

func (l *HttpListener) AddLogger() *HttpListener

func (*HttpListener) GetApiPrefix added in v0.0.8

func (l *HttpListener) GetApiPrefix() string

func (*HttpListener) Probe

func (c *HttpListener) Probe() controllers.Controller

Login Generate a token for a valid user

func (*HttpListener) ShutdownHandler

func (s *HttpListener) ShutdownHandler(w http.ResponseWriter, r *http.Request)

func (*HttpListener) Start

func (l *HttpListener) Start()

func (*HttpListener) WaitAndShutdown

func (l *HttpListener) WaitAndShutdown()

func (*HttpListener) WithPublicUserRegistration added in v0.0.6

func (l *HttpListener) WithPublicUserRegistration() *HttpListener

type HttpListenerOptions

type HttpListenerOptions struct {
	ApiPrefix               string
	HttpPort                string
	EnableTLS               bool
	TLSPort                 string
	TLSCertificate          string
	TLSPrivateKey           string
	UseAuthBackend          bool
	MongoDbConnectionString string
	DatabaseName            string
	EnableAuthentication    bool
	LogHealthChecks         bool
	PublicRegistration      bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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