import "github.com/Hexilee/gotten"
Checker.go Client.go Creator.go ErrorMessages.go Reader.go RequestFields.go Response.go TagKeys.go Unmarshaler.go UrlCtr.go VarsCtr.go interfaceTypes.go
const ( BaseUrlCannotBeEmpty = "baseUrl cannot be empty" MustPassPtrToImpl = "must pass the ptr of the service to be implemented" ServiceMustBeStruct = "service must be struct" UnrecognizedHTTPMethod = "http method is unrecognized" ParamTypeMustBePtrOfStruct = "param type must be ptr of struct" ValueIsNotString = "value is not a string" ValueIsNotInt = "value is not a int" DuplicatedPathKey = "duplicated path key" UnsupportedValueType = "field type is unrecognized" UnrecognizedPathKey = "path key is unrecognized" EmptyRequiredVariable = "required variable is empty" UnsupportedFieldType = "field type is unsupported" SomePathVarHasNoValue = "some pathValue has no value" NoUnmarshalerFoundForResponse = "no unmarshaler found for response" ContentTypeConflict = "content type conflict: " UnsupportedFuncType = "function type is not supported" )
const ( // support types: fmt.Stringer, int, string TypeHeader = "header" // support types: fmt.Stringer, int, string TypePath = "path" // support types: fmt.Stringer, int, string TypeQuery = "query" // support types: fmt.Stringer, int, string TypeForm = "form" // support types: fmt.Stringer, int, string TypeCookie = "cookie" // support types: fmt.Stringer, int, string, Reader, FilePath TypeMultipart = "part" // support types: fmt.Stringer, Reader, string, struct, slice, map TypeJSON = "json" // support types: fmt.Stringer, Reader, string, struct, slice, map TypeXML = "xml" )
value types
const ( KeyKey = "key" KeyMethod = "method" KeyType = "type" //KeyStatus = "status" KeyPath = "path" KeyDefault = "default" KeyRequire = "require" )
const ( PathKeyRegexp = `\{[a-zA-Z_][0-9a-zA-Z_]*\}` ZeroStr = "" // json Marshal nil NullStr = "null" ZeroInt = 0 )
var ( FilePathType = reflect.TypeOf(filePath) IntType = reflect.TypeOf(int(1)) StringType = reflect.TypeOf("") )
var ( ZeroStringer fmt.Stringer = bytes.NewBufferString("") ZeroReader io.Reader = bytes.NewBufferString("") )
var ( StringerType = typesValue.FieldByName("stringer").Type() ReaderType = typesValue.FieldByName("reader").Type() ErrorType = typesValue.FieldByName("error").Type() ResponseType = typesValue.FieldByName("response").Type() RequestType = typesValue.FieldByName("request").Type() )
var ( DefaultUnmarshalers = []*ConditionalUnmarshaler{ { NewReaderAdapter(UnmarshalAdapter(json.Unmarshal)), new(CheckerFactory).WhenContentType( headers.MIMEApplicationJSON, headers.MIMEApplicationJSONCharsetUTF8, ).Create(), }, { NewReaderAdapter(UnmarshalAdapter(xml.Unmarshal)), new(CheckerFactory).WhenContentType( headers.MIMEApplicationXML, headers.MIMEApplicationXMLCharsetUTF8, headers.MIMETextXML, headers.MIMETextXMLCharsetUTF8, ).Create(), }, { NewReaderAdapter(UnmarshalAdapter(unhtml.Unmarshal)), new(CheckerFactory).WhenContentType( headers.MIMETextHTML, headers.MIMETextHTMLCharsetUTF8, ).Create(), }, } )
func SomePathVarHasNoValueError(list PathKeyList) error
type Builder struct {
// contains filtered or unexported fields
}
func (builder *Builder) AddReadUnmarshalFunc(unmarshaler ReadUnmarshalFunc, checker Checker) *Builder
func (builder *Builder) AddReaderUnmarshaler(unmarshaler ReadUnmarshaler, checker Checker) *Builder
func (builder *Builder) AddUnmarshalFunc(unmarshaler UnmarshalFunc, checker Checker) *Builder
func (builder *Builder) AddUnmarshaler(unmarshaler Unmarshaler, checker Checker) *Builder
type CheckerFactory struct {
// contains filtered or unexported fields
}
func (factory *CheckerFactory) Create() (checker CheckerFunc)
func (factory *CheckerFactory) When(key string, values ...string) *CheckerFactory
func (factory *CheckerFactory) WhenContentType(values ...string) *CheckerFactory
func (factory *CheckerFactory) WhenStatuses(statuses ...int) *CheckerFactory
func (fn CheckerFunc) Check(resp *http.Response) bool
type ConditionalUnmarshaler struct {
// contains filtered or unexported fields
}
type ConditionalUnmarshalers []*ConditionalUnmarshaler
func (unmarshalers ConditionalUnmarshalers) Check(response *http.Response) (unmarshaler ReadUnmarshaler, exist bool)
type Creator struct {
// contains filtered or unexported fields
}
func(*params) (*http.Request, error) || func(*params) (gotten.Response, error)
type Field struct {
// contains filtered or unexported fields
}
TypePath, TypeQuery, TypeForm, TypeHeader, TypeCookie, TypeMultipart(except io.Reader)
type IOField struct {
// contains filtered or unexported fields
}
TypeJSON, TypeXML, TypeMultipart(io.Reader)
type MultipartReader struct {
// contains filtered or unexported fields
}
type ReadCloser interface { io.ReadCloser Empty() bool }
func (fn ReadUnmarshalFunc) Unmarshal(reader io.ReadCloser, header http.Header, v interface{}) error
type ReadUnmarshaler interface { Unmarshal(reader io.ReadCloser, header http.Header, v interface{}) error }
func NewReaderAdapter(unmarshaler Unmarshaler) ReadUnmarshaler
type ReaderAdapter struct {
// contains filtered or unexported fields
}
func (adapter *ReaderAdapter) Unmarshal(reader io.ReadCloser, header http.Header, v interface{}) (err error)
type ReaderImpl struct {
// contains filtered or unexported fields
}
func (reader ReaderImpl) Close() (err error)
func (reader ReaderImpl) Empty() bool
func (reader ReaderImpl) Read(p []byte) (n int, err error)
type Response interface { StatusCode() int Header() http.Header Body() io.ReadCloser ContentType() string Cookies() []*http.Cookie // Location returns the URL of the response's "Location" header, // if present. Relative redirects are resolved relative to // the Response's Request. ErrNoLocation is returned if no // Location header is present. Location() (*url.URL, error) // ProtoAtLeast reports whether the HTTP protocol used // in the response is at least major.minor. ProtoAtLeast(major, minor int) bool Unmarshal(ptr interface{}) error }
func (resp ResponseImpl) Body() io.ReadCloser
func (resp ResponseImpl) ContentType() string
func (resp ResponseImpl) Header() http.Header
func (resp ResponseImpl) StatusCode() int
func (resp ResponseImpl) Unmarshal(ptr interface{}) error
type Types struct {
// contains filtered or unexported fields
}
func (fn UnmarshalFunc) Unmarshal(data []byte, v interface{}) error
func UnmarshalAdapter(fn UnmarshalFunc) Unmarshaler
type UrlCtr struct {
// contains filtered or unexported fields
}
type VarsController interface {
// contains filtered or unexported methods
}
type VarsCtr struct {
// contains filtered or unexported fields
}
type VarsParser struct {
// contains filtered or unexported fields
}
func (parser *VarsParser) Build() VarsController
Path | Synopsis |
---|---|
example | |
headers | |
mock | |
unmarshalers |
Package gotten imports 21 packages (graph) and is imported by 3 packages. Updated 2018-11-21. Refresh now. Tools for package owners.