goat: github.com/bahlo/goat Index | Files

package goat

import "github.com/bahlo/goat"


Package Files

goat.go index.go json.go middleware.go params.go router.go

func WriteError Uses

func WriteError(w http.ResponseWriter, code int, err string)

WriteError writes a string as JSON encoded error

func WriteJSON Uses

func WriteJSON(w http.ResponseWriter, v interface{}) error

WriteJSON writes the given interface as JSON or returns an error

func WriteJSONWithStatus Uses

func WriteJSONWithStatus(w http.ResponseWriter, code int, v interface{}) error

WriteJSONWithStatus writes the given statuscode into the header and the given interface as JSON or returns an error

type Handle Uses

type Handle func(http.ResponseWriter, *http.Request, Params)

Handle describes the function that should be used by handlers

type Middleware Uses

type Middleware func(http.Handler) http.Handler

Middleware reprents a default middleware function

type Params Uses

type Params map[string]string

Params represents the parameters of a request

type Router Uses

type Router struct {
    // contains filtered or unexported fields

Router represents a router

func New Uses

func New() *Router

New creates a new Router and returns it

func (*Router) Delete Uses

func (r *Router) Delete(path, title string, fn Handle)

Delete adds a DELETE route

func (*Router) Get Uses

func (r *Router) Get(path, title string, fn Handle)

Get adds a GET route

func (*Router) Index Uses

func (r *Router) Index() map[string]string

Index returns a string map with the titles and urls of all GET routes

func (*Router) IndexHandler Uses

func (r *Router) IndexHandler(w http.ResponseWriter, _ *http.Request, _ Params)

IndexHandler writes the index of all GET methods to the ResponseWriter

func (*Router) Options Uses

func (r *Router) Options(path, title string, fn Handle)

Options adds a OPTIONS route

func (*Router) Post Uses

func (r *Router) Post(path, title string, fn Handle)

Post adds a POST route

func (*Router) Put Uses

func (r *Router) Put(path, title string, fn Handle)

Put adds a PUT route

func (*Router) Run Uses

func (r *Router) Run(address string) error

Run starts the server

func (*Router) RunTLS Uses

func (r *Router) RunTLS(addr, certFile, keyFile string) error

RunTLS starts the server, but expects HTTPS connections

func (*Router) ServeHTTP Uses

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler

func (*Router) Subrouter Uses

func (r *Router) Subrouter(path string) *Router

Subrouter creates and returns a subrouter

func (*Router) Use Uses

func (r *Router) Use(middleware ...Middleware)

Use adds middleware to the router

Package goat imports 4 packages (graph). Updated 2018-02-17. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).