Documentation ¶
Overview ¶
Package API is a reusable back-end API framework used on https://noahfriedman.ca.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRouter ¶
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.
Types ¶
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.