package module
Version: v0.1.1 Latest Latest

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

Go to latest
Published: Mar 16, 2021 License: AGPL-3.0 Imports: 7 Imported by: 1


noahfriedman.ca/api CI/CD

A reusable back-end API framework used on noahfriedman.ca. Built on top of the gorilla/mux router.



Package API is a reusable back-end API framework used on https://noahfriedman.ca.



This section is empty.


This section is empty.


func NewRouter

func NewRouter(funcs []http.HandlerFunc, routePath string, noCORS bool) *mux.Router

NewRouter creates a mux.Router that is preconfigured to properly route the provided API functions (funcs) using the provided routePath.

In order for function names to be parsed properly, functions in the funcs array must be defined as follows:

func ExampleFunc() {...

as opposed to:

ExampleFunc := func() {...

If noCORS is 'true', the router will automatically add

Access-Control-Allow-Origin: *

to all HTTP headers. This way if all API functions require a universal CORS policy, it doesn't need to be implemented in each individual function.


type FunctionList

type FunctionList struct {
	Available []string `json:"available"`

FunctionList is a struct used for marshalling and unmarshalling a JSON object describing what functions are available within an API. These functions are defined by the funcs array in the NewRouter function.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL