api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORS

func GetLink(w http.ResponseWriter, r *http.Request, ps httprouter.Params, c *Config)

func GetRandom

func GetRandom(w http.ResponseWriter, r *http.Request, ps httprouter.Params, c *Config)

func InjectConfig

Wraps an endpoint handler with a function that has access to a Config

func NewRouter

func NewRouter(config *Config) *httprouter.Router
func PostLink(w http.ResponseWriter, r *http.Request, ps httprouter.Params, c *Config)

We expect a multipart/form-data request containing:

  • an optional "image"
  • a "json" with the expected input as values

Types

type Config

type Config struct {
	RootPath       string
	Template       *template.Template
	LinkStore      links.Store
	ImageStore     images.Store
	ImageMaxWidth  int
	ImageMaxHeight int
}

Config is a container for all the interfaces and configuration options the API uses. It will be injected to the endpoints in order to allow them to access these options in a DI way

type PostLinkInput

type PostLinkInput struct {
	Link links.Link `json:"link"`
}

type PostLinkOutput

type PostLinkOutput struct {
	Slug string `json:"slug"`
}

Jump to

Keyboard shortcuts

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