api

package
v0.0.0-...-69798c4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_OVERRIDE_URL_HEADER       = "X-API-request-url"
	DEFAULT_OVERRIDE_CLIENT_IP_HEADER = "X-API-client-ip"
	FORWARDED_FOR_HEADER              = "X-Forwarded-For"
	FORWARDED_HOST_HEADER             = "X-Forwarded-Host"
	FORWARDED_PROTO_HEADER            = "X-Forwarded-Proto"
	FORWARDED_PORT_HEADER             = "X-Forwarded-Port"
	SELF                              = "self"
	COLLECTION                        = "collection"
	LATEST                            = "latest"
	HTML                              = "html"
	JSON                              = "json"
)

Variables

This section is empty.

Functions

func ApiHandler

func ApiHandler(schemas *client.Schemas, f http.Handler) http.Handler

func CollectionToMap

func CollectionToMap(obj interface{}, schemas *client.Schemas) (map[string]interface{}, []map[string]interface{}, error)

func CreateApiContext

func CreateApiContext(rw http.ResponseWriter, r *http.Request, schemas *client.Schemas) error

func IsBrowser

func IsBrowser(r *http.Request, checkAccepts bool) bool

func ResourceToMap

func ResourceToMap(obj interface{}, schemas *client.Schemas) (map[string]interface{}, error)

func SchemaHandler

func SchemaHandler(schemas *client.Schemas) http.Handler

func SchemasHandler

func SchemasHandler(schemas *client.Schemas) http.Handler

func VersionHandler

func VersionHandler(schemas *client.Schemas, version string) http.Handler

func VersionsHandler

func VersionsHandler(schemas *client.Schemas, versions ...string) http.Handler

Types

type ApiContext

type ApiContext struct {
	UrlBuilder UrlBuilder
	// contains filtered or unexported fields
}

func GetApiContext

func GetApiContext(r *http.Request) *ApiContext

func (*ApiContext) Write

func (a *ApiContext) Write(obj interface{})

func (*ApiContext) WriteCollection

func (a *ApiContext) WriteCollection(obj interface{}) error

func (*ApiContext) WriteResource

func (a *ApiContext) WriteResource(obj interface{}) error

type ApiResponseWriter

type ApiResponseWriter interface {
	Write(obj interface{}, rw http.ResponseWriter) error
}

type HtmlWriter

type HtmlWriter struct {
	CssUrl, JsUrl string
	// contains filtered or unexported fields
}

func (*HtmlWriter) Write

func (j *HtmlWriter) Write(obj interface{}, rw http.ResponseWriter) error

type JsonWriter

type JsonWriter struct {
	// contains filtered or unexported fields
}

func (*JsonWriter) Write

func (j *JsonWriter) Write(obj interface{}, rw http.ResponseWriter) error

type UrlBuilder

type UrlBuilder interface {
	//ActionLink(resource client.Resource, name string) string
	Current() string
	Collection(resourceType string) string
	Link(resource client.Resource, name string) string
	ReferenceLink(resource client.Resource) string
	ReferenceByIdLink(resourceType string, id string) string
	Version(version string) string
}

func NewUrlBuilder

func NewUrlBuilder(r *http.Request, schemas *client.Schemas) (UrlBuilder, error)

Jump to

Keyboard shortcuts

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