httpdoc

package
v0.0.0-...-3877e5c Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.1.0"

Version is the current version of the package

Variables

View Source
var (
	// ErrUnknownResource is returned by GetResourceFor if it can’t find a
	// resource
	ErrUnknownResource = errors.New("Unknown resource")

	// ErrUnknownStatusCode is returned by GetStatusCode if it can’t find a
	// status code
	ErrUnknownStatusCode = errors.New("Unknown status code")

	// ErrUnknownHeader is returned by GetHeader if it can’t find an header
	// field
	ErrUnknownHeader = errors.New("Unknown header field")

	// ErrUnknownMethod is returned by GetMethod if it can’t find a method
	ErrUnknownMethod = errors.New("Unknown method")
)

Functions

This section is empty.

Types

type Doc

type Doc struct {
	// the root dir in which are the documentation files
	RootDir string
}

Doc represents a documentation source

var DefaultDoc Doc

DefaultDoc is a Doc which assumes you installed the binary/library using `go get`.

func (Doc) GetHeader

func (d Doc) GetHeader(name string) (h Header, err error)

GetHeader returns a Header

func (Doc) GetMethod

func (d Doc) GetMethod(name string) (m Method, err error)

GetMethod returns a Method from its verb

func (Doc) GetResourceFor

func (d Doc) GetResourceFor(name string) (Resource, error)

GetResourceFor gets a name and tries to find a corresponding resource. It'll return ErrUnknownResource if it can’t find it.

func (Doc) GetStatusCode

func (d Doc) GetStatusCode(code string) (c StatusCode, err error)

GetStatusCode gets a code and returns a new StatusCode struct describing it. If it can’t find the code an ErrUnknownStatusCode is returned.

type Header struct {
	// Type is either "request", "response", or "both"
	Type string

	// Text is the header’s text
	Text string

	// Desc is an human-readable description of the header
	Desc string

	// Refs are some references for the reader
	Refs []string
}

Header is an HTTP header field

func (Header) PrettyString

func (h Header) PrettyString() string

PrettyString returns an human-readable description of the header

func (Header) String

func (h Header) String() string

type Method

type Method struct {
	// Verb is the method’s verb
	Verb string

	// Desc is an human-readable description of the method
	Desc string

	// Refs are some references for the reader
	Refs []string
}

Method is an HTTP method

func (Method) PrettyString

func (m Method) PrettyString() string

PrettyString returns an human-readable description of this method

func (Method) String

func (m Method) String() string

type NilResource

type NilResource struct{}

NilResource is an empty resource

var InvalidResource NilResource

InvalidResource is returned by some functions where a Resource is needed but no one can be found

func (NilResource) PrettyString

func (n NilResource) PrettyString() string

PrettyString returns an empty string

func (NilResource) String

func (n NilResource) String() string

type Resource

type Resource interface {
	String() string

	// PrettyString is intended as a more verbose `String()` for user display
	PrettyString() string
}

A Resource is a documented resource

type StatusCode

type StatusCode struct {
	// Code is its actual code (e.g. "200")
	Code string

	// Text is a short text describing the status code (e.g. "OK")
	Text string

	// Desc is an human-readable description of the status code
	Desc string

	// Refs are some references for the reader
	Refs []string
}

A StatusCode is an HTTP status code

func (StatusCode) PrettyString

func (c StatusCode) PrettyString() string

PrettyString returns a string describing the status code with a long description and a references list.

func (StatusCode) String

func (c StatusCode) String() string

Jump to

Keyboard shortcuts

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