server

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2021 License: MIT Imports: 5 Imported by: 0

README

go-starter-server

A library built to bootstrap the process of getting a web server started in golang. This was built for my own personal use, but feel free to use it if you wish.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureTemplates

func ConfigureTemplates(templateFolderUri string)

This function takes a URI and uses that as the base location to parse all of your html templates.

func NewRouter

func NewRouter(corsOptionsParam *cors.Options) *mux.Router

This will create a new Gorilla Mux router that will call router.Handle and router.Methods on the routeArray variable in this file. It also will set up any global middleware defined through AddGlibalMiddleware

func RegisterGlobalMiddleware

func RegisterGlobalMiddleware(fn mux.MiddlewareFunc)

func RegisterRoute

func RegisterRoute(newRoute Route)

Allows users of the library to add routes to the server. This is done this way to enforce inversion of control. The services should push the routes to the router. The router shouldn't pull the routes from them.

func RenderTemplate

func RenderTemplate(w http.ResponseWriter, template string, model interface{})

This is a handler that will take a template name and appends the .html extention. It will then serve the html template. If you pass a model, it will attempt to use that model to fill out the template when it is parsed.

Types

type Route

type Route struct {
	Name        string
	Method      string
	Path        string
	HandlerFunc http.HandlerFunc
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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