rs

package
v0.0.0-...-0fa378f Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package rs is a library for implementing RESTful APIs, inspired by JAX-RS Once it is mature, it should probably be carved out into its own library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpErrorObject

type HttpErrorObject struct {
	Status  int
	Message string

	Headers map[string]string
}

func ErrNotFound

func ErrNotFound() *HttpErrorObject

func HttpError

func HttpError(status int) *HttpErrorObject

func (*HttpErrorObject) Error

func (self *HttpErrorObject) Error() string

type HttpResponse

type HttpResponse struct {
	Status  int
	Content interface{}
	Headers map[string]string
}

type JsonMessageBodyReader

type JsonMessageBodyReader struct {
}

func NewJsonMessageBodyReader

func NewJsonMessageBodyReader() *JsonMessageBodyReader

func (*JsonMessageBodyReader) IsReadable

func (self *JsonMessageBodyReader) IsReadable(t reflect.Type, req *http.Request, mediaType *MediaType) bool

func (*JsonMessageBodyReader) Read

func (self *JsonMessageBodyReader) Read(t reflect.Type, req *http.Request, mediaType *MediaType) (interface{}, error)

type JsonMessageBodyWriter

type JsonMessageBodyWriter struct {
}

func NewJsonMessageBodyWriter

func NewJsonMessageBodyWriter() *JsonMessageBodyWriter

func (*JsonMessageBodyWriter) IsWritable

func (self *JsonMessageBodyWriter) IsWritable(t reflect.Type, req *http.Request, mediaType *MediaType) bool

func (*JsonMessageBodyWriter) Write

func (self *JsonMessageBodyWriter) Write(o interface{}, t reflect.Type, req *http.Request, res http.ResponseWriter) error

type MediaType

type MediaType struct {
	Type       string
	Subtype    string
	Parameters map[string]string
	// contains filtered or unexported fields
}

func ParseMediaType

func ParseMediaType(t string) (*MediaType, error)

func (*MediaType) Is

func (self *MediaType) Is(match string) bool

type MessageBodyReader

type MessageBodyReader interface {
	IsReadable(t reflect.Type, req *http.Request, mediaType *MediaType) bool
	Read(t reflect.Type, req *http.Request, mediaType *MediaType) (interface{}, error)
}

type MessageBodyWriter

type MessageBodyWriter interface {
	IsWritable(t reflect.Type, req *http.Request, mediaType *MediaType) bool
	Write(obj interface{}, t reflect.Type, req *http.Request, res http.ResponseWriter) error
}

type NoResponseMessageBodyWriter

type NoResponseMessageBodyWriter struct {
}

func (*NoResponseMessageBodyWriter) IsWritable

func (self *NoResponseMessageBodyWriter) IsWritable(t reflect.Type, req *http.Request, mediaType *MediaType) bool

func (*NoResponseMessageBodyWriter) Write

func (self *NoResponseMessageBodyWriter) Write(o interface{}, t reflect.Type, req *http.Request, res http.ResponseWriter) error

type RestEndpointHandler

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

type RestServer

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

func NewRestServer

func NewRestServer() *RestServer

func (*RestServer) AddEndpoint

func (self *RestServer) AddEndpoint(path string, t reflect.Type) *RestEndpointHandler

func (*RestServer) AddReader

func (self *RestServer) AddReader(mbr MessageBodyReader)

func (*RestServer) AddWriter

func (self *RestServer) AddWriter(mbw MessageBodyWriter)

func (*RestServer) ListenAndServe

func (self *RestServer) ListenAndServe() error

func (*RestServer) SetListen

func (self *RestServer) SetListen(listen string)

func (*RestServer) WithInjector

func (self *RestServer) WithInjector(injector inject.Injector)

Jump to

Keyboard shortcuts

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