app

package
v0.0.0-...-37d92c4 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigAndRunApp

func ConfigAndRunApp(config *config.Config)

ConfigAndRunApp will create and initialize App structure. App factory function.

Types

type App

type App struct {
	Router *mux.Router
	DB     *mongo.Database
}

App has the mongo database and router instances

func (*App) Delete

func (app *App) Delete(path string, endpoint http.HandlerFunc, queries ...string)

Delete will register Delete method for an endpoint

func (*App) Get

func (app *App) Get(path string, endpoint http.HandlerFunc, queries ...string)

Get will register Get method for an endpoint

func (*App) Initialize

func (app *App) Initialize(config *config.Config)

Initialize initialize the app with

func (*App) Patch

func (app *App) Patch(path string, endpoint http.HandlerFunc, queries ...string)

Patch will register Patch method for an endpoint

func (*App) Post

func (app *App) Post(path string, endpoint http.HandlerFunc, queries ...string)

Post will register Post method for an endpoint

func (*App) Put

func (app *App) Put(path string, endpoint http.HandlerFunc, queries ...string)

Put will register Put method for an endpoint

func (*App) Run

func (app *App) Run(host string)

Run will start the http server on host that you pass in. host:<ip:port>

func (*App) UseMiddleware

func (app *App) UseMiddleware(middleware mux.MiddlewareFunc)

UseMiddleware will add global middleware in router

type RequestHandlerFunction

type RequestHandlerFunction func(db *mongo.Database, w http.ResponseWriter, r *http.Request)

RequestHandlerFunction is a custome type that help us to pass db arg to all endpoints

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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