doc

package
v0.0.0-...-2da5c5d Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2017 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyHeader

func CopyHeader(dst, src http.Header)

Types

type Action

type Action struct {
	Title       string
	Description string
	Method      HTTPMethod
	Requests    []*Request
}

func NewAction

func NewAction(method, handlerName string) (*Action, error)

func NewJSONRPCAction

func NewJSONRPCAction(httpMethod string, body []byte) (*Action, error)

func (*Action) AddRequest

func (a *Action) AddRequest(req *Request, resp *Response)

func (*Action) Render

func (a *Action) Render() string

type Body

type Body struct {
	Content     []byte
	ContentType string
}

func NewBody

func NewBody(content []byte, contentType string) (b *Body)

func (*Body) FormattedJSON

func (b *Body) FormattedJSON() string

func (*Body) FormattedStr

func (b *Body) FormattedStr() string

func (*Body) Render

func (b *Body) Render() string

type Doc

type Doc struct {
	Group ResourceGroup
	// contains filtered or unexported fields
}

func NewDoc

func NewDoc(pkgDir string) (doc *Doc, err error)

func (*Doc) AddResource

func (d *Doc) AddResource(resource *Resource)

TODO: add Resource to appropriate ResourceGroup,

not just to ResourceGroups[0]

func (*Doc) Write

func (d *Doc) Write() error

type HTTPMethod

type HTTPMethod string
type Header struct {
	DisplayHeader http.Header
	ContentType   string
}

func NewHeader

func NewHeader(h http.Header) *Header

func (Header) Render

func (h Header) Render() string

type JSONRPCRequest

type JSONRPCRequest struct {
	JsonRpc string          `json:"jsonrpc"`
	ID      uint32          `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"`
}

Helper for jsonrpc calls

type Metadata

type Metadata struct {
	Format string
	Host   string
}

type Parameter

type Parameter struct {
	Name        string
	Description string
	Value       ParameterValue
	Type        ParameterType
	IsRequired  bool
}

func MakeParameter

func MakeParameter(key, val string) Parameter

func (*Parameter) Render

func (p *Parameter) Render() string

type ParameterType

type ParameterType int
const (
	Number ParameterType = iota
	String
	Boolean
)

func (ParameterType) String

func (pt ParameterType) String() string

type ParameterValue

type ParameterValue string

func (ParameterValue) Quote

func (val ParameterValue) Quote() (qval string)

type Request

type Request struct {
	Header   *Header
	Body     *Body
	Method   string
	Response *Response
}

func NewRequest

func NewRequest(req *http.Request) (*Request, error)

func (*Request) HasBody

func (r *Request) HasBody() bool

func (*Request) HasContentType

func (r *Request) HasContentType() bool

func (*Request) HasHeader

func (r *Request) HasHeader() bool

func (*Request) Render

func (r *Request) Render() string

type Resource

type Resource struct {
	Title       string
	Description string
	//Model       *Model
	URL     *URL
	Actions map[HTTPMethod]*Action
}

func NewResource

func NewResource(u *URL) *Resource

NewResource returns a new Resource object

func (*Resource) AddAction

func (r *Resource) AddAction(action *Action)

func (*Resource) FindAction

func (r *Resource) FindAction(httpMethod string) *Action

func (*Resource) Render

func (r *Resource) Render() string

type ResourceGroup

type ResourceGroup struct {
	Title       string
	Description string
	Resources   []Resource
}

func (*ResourceGroup) Render

func (rg *ResourceGroup) Render() string

type Response

type Response struct {
	StatusCode  int
	Description string
	Header      *Header
	Body        *Body
}

func NewResponse

func NewResponse(resp *httptest.ResponseRecorder) *Response

func (*Response) HasContentType

func (r *Response) HasContentType() bool

func (*Response) Render

func (r *Response) Render() string

type URL

type URL struct {
	ParameterizedPath string
	Parameters        []Parameter
	// contains filtered or unexported fields
}

func NewJSONRPCUrl

func NewJSONRPCUrl(req *http.Request, body []byte) *URL

func NewURL

func NewURL(req *http.Request) *URL

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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