api_session

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCode_Continue           _type.StatusCode = 100 // RFC 7231, 6.2.1
	StatusCode_SwitchingProtocols _type.StatusCode = 101 // RFC 7231, 6.2.2
	StatusCode_Processing         _type.StatusCode = 102 // RFC 2518, 10.1

	StatusCode_OK                   _type.StatusCode = 200 // RFC 7231, 6.3.1
	StatusCode_Created              _type.StatusCode = 201 // RFC 7231, 6.3.2
	StatusCode_Accepted             _type.StatusCode = 202 // RFC 7231, 6.3.3
	StatusCode_NonAuthoritativeInfo _type.StatusCode = 203 // RFC 7231, 6.3.4
	StatusCode_NoContent            _type.StatusCode = 204 // RFC 7231, 6.3.5
	StatusCode_ResetContent         _type.StatusCode = 205 // RFC 7231, 6.3.6
	StatusCode_PartialContent       _type.StatusCode = 206 // RFC 7233, 4.1
	StatusCode_MultiStatus          _type.StatusCode = 207 // RFC 4918, 11.1
	StatusCode_AlreadyReported      _type.StatusCode = 208 // RFC 5842, 7.1
	StatusCode_IMUsed               _type.StatusCode = 226 // RFC 3229, 10.4.1

	StatusCode_MultipleChoices  _type.StatusCode = 300 // RFC 7231, 6.4.1
	StatusCode_MovedPermanently _type.StatusCode = 301 // RFC 7231, 6.4.2
	StatusCode_Found            _type.StatusCode = 302 // RFC 7231, 6.4.3
	StatusCode_SeeOther         _type.StatusCode = 303 // RFC 7231, 6.4.4
	StatusCode_NotModified      _type.StatusCode = 304 // RFC 7232, 4.1
	StatusCode_UseProxy         _type.StatusCode = 305 // RFC 7231, 6.4.5

	StatusCode_TemporaryRedirect _type.StatusCode = 307 // RFC 7231, 6.4.7
	StatusCode_PermanentRedirect _type.StatusCode = 308 // RFC 7538, 3

	StatusCode_BadRequest                   _type.StatusCode = 400 // RFC 7231, 6.5.1
	StatusCode_Unauthorized                 _type.StatusCode = 401 // RFC 7235, 3.1
	StatusCode_PaymentRequired              _type.StatusCode = 402 // RFC 7231, 6.5.2
	StatusCode_Forbidden                    _type.StatusCode = 403 // RFC 7231, 6.5.3
	StatusCode_NotFound                     _type.StatusCode = 404 // RFC 7231, 6.5.4
	StatusCode_MethodNotAllowed             _type.StatusCode = 405 // RFC 7231, 6.5.5
	StatusCode_NotAcceptable                _type.StatusCode = 406 // RFC 7231, 6.5.6
	StatusCode_ProxyAuthRequired            _type.StatusCode = 407 // RFC 7235, 3.2
	StatusCode_RequestTimeout               _type.StatusCode = 408 // RFC 7231, 6.5.7
	StatusCode_Conflict                     _type.StatusCode = 409 // RFC 7231, 6.5.8
	StatusCode_Gone                         _type.StatusCode = 410 // RFC 7231, 6.5.9
	StatusCode_LengthRequired               _type.StatusCode = 411 // RFC 7231, 6.5.10
	StatusCode_PreconditionFailed           _type.StatusCode = 412 // RFC 7232, 4.2
	StatusCode_RequestEntityTooLarge        _type.StatusCode = 413 // RFC 7231, 6.5.11
	StatusCode_RequestURITooLong            _type.StatusCode = 414 // RFC 7231, 6.5.12
	StatusCode_UnsupportedMediaType         _type.StatusCode = 415 // RFC 7231, 6.5.13
	StatusCode_RequestedRangeNotSatisfiable _type.StatusCode = 416 // RFC 7233, 4.4
	StatusCode_ExpectationFailed            _type.StatusCode = 417 // RFC 7231, 6.5.14
	StatusCode_Teapot                       _type.StatusCode = 418 // RFC 7168, 2.3.3
	StatusCode_MisdirectedRequest           _type.StatusCode = 421 // RFC 7540, 9.1.2
	StatusCode_UnprocessableEntity          _type.StatusCode = 422 // RFC 4918, 11.2
	StatusCode_Locked                       _type.StatusCode = 423 // RFC 4918, 11.3
	StatusCode_FailedDependency             _type.StatusCode = 424 // RFC 4918, 11.4
	StatusCode_TooEarly                     _type.StatusCode = 425 // RFC 8470, 5.2.
	StatusCode_UpgradeRequired              _type.StatusCode = 426 // RFC 7231, 6.5.15
	StatusCode_PreconditionRequired         _type.StatusCode = 428 // RFC 6585, 3
	StatusCode_TooManyRequests              _type.StatusCode = 429 // RFC 6585, 4
	StatusCode_RequestHeaderFieldsTooLarge  _type.StatusCode = 431 // RFC 6585, 5
	StatusCode_UnavailableForLegalReasons   _type.StatusCode = 451 // RFC 7725, 3

	StatusCode_InternalServerError           _type.StatusCode = 500 // RFC 7231, 6.6.1
	StatusCode_NotImplemented                _type.StatusCode = 501 // RFC 7231, 6.6.2
	StatusCode_BadGateway                    _type.StatusCode = 502 // RFC 7231, 6.6.3
	StatusCode_ServiceUnavailable            _type.StatusCode = 503 // RFC 7231, 6.6.4
	StatusCode_GatewayTimeout                _type.StatusCode = 504 // RFC 7231, 6.6.5
	StatusCode_HTTPVersionNotSupported       _type.StatusCode = 505 // RFC 7231, 6.6.6
	StatusCode_VariantAlsoNegotiates         _type.StatusCode = 506 // RFC 2295, 8.1
	StatusCode_InsufficientStorage           _type.StatusCode = 507 // RFC 4918, 11.5
	StatusCode_LoopDetected                  _type.StatusCode = 508 // RFC 5842, 7.2
	StatusCode_NotExtended                   _type.StatusCode = 510 // RFC 2774, 7
	StatusCode_NetworkAuthenticationRequired _type.StatusCode = 511 // RFC 6585, 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiMethod

type ApiMethod string
const (
	ApiMethod_Post   ApiMethod = `POST`
	ApiMethod_Get    ApiMethod = `GET`
	ApiMethod_Option ApiMethod = `OPTIONS`
	ApiMethod_All    ApiMethod = `ALL`
)

type ApiSessionClass

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

func NewApiSession

func NewApiSession() *ApiSessionClass

func (*ApiSessionClass) AddDefer

func (apiSession *ApiSessionClass) AddDefer(defer_ func())

Add defer handler. Defer handlers will be executed by order at the end of api session.

func (*ApiSessionClass) Api

func (apiSession *ApiSessionClass) Api() _interface.IApi

func (*ApiSessionClass) Body added in v1.2.2

func (apiSession *ApiSessionClass) Body() io.ReadCloser

Get request body.

func (*ApiSessionClass) ClientType

func (apiSession *ApiSessionClass) ClientType() string

func (*ApiSessionClass) Data added in v1.2.2

func (apiSession *ApiSessionClass) Data(key string) interface{}

func (*ApiSessionClass) Defers

func (apiSession *ApiSessionClass) Defers() []func()

func (*ApiSessionClass) FormValues added in v1.2.2

func (apiSession *ApiSessionClass) FormValues() (map[string][]string, error)

Read form data from request.

func (*ApiSessionClass) Header added in v1.2.2

func (apiSession *ApiSessionClass) Header(name string) string

Read header by key from request headers.

func (*ApiSessionClass) Host added in v1.2.2

func (apiSession *ApiSessionClass) Host() string

Get request host.

func (*ApiSessionClass) JwtBody

func (apiSession *ApiSessionClass) JwtBody() map[string]interface{}

func (*ApiSessionClass) JwtHeaderName

func (apiSession *ApiSessionClass) JwtHeaderName() string

func (*ApiSessionClass) Lang

func (apiSession *ApiSessionClass) Lang() string

func (*ApiSessionClass) Logger added in v1.2.2

func (apiSession *ApiSessionClass) Logger() go_logger.InterfaceLogger

func (*ApiSessionClass) Method added in v1.2.2

func (apiSession *ApiSessionClass) Method() string

Get request method (GET, POST, PUT, etc.).

func (*ApiSessionClass) MustScanParams added in v1.2.6

func (apiSession *ApiSessionClass) MustScanParams(dest interface{})

func (*ApiSessionClass) OriginalParams

func (apiSession *ApiSessionClass) OriginalParams() map[string]interface{}

func (*ApiSessionClass) Params

func (apiSession *ApiSessionClass) Params() map[string]interface{}

func (*ApiSessionClass) Path added in v1.2.2

func (apiSession *ApiSessionClass) Path() string

Get request path.

func (*ApiSessionClass) PathVars added in v1.2.2

func (apiSession *ApiSessionClass) PathVars() map[string]string

func (*ApiSessionClass) ReadJSON

func (apiSession *ApiSessionClass) ReadJSON(jsonObject interface{}) error

Read json data from request body.

func (*ApiSessionClass) Redirect added in v1.2.3

func (apiSession *ApiSessionClass) Redirect(url string)

func (*ApiSessionClass) RemoteAddress added in v1.2.2

func (apiSession *ApiSessionClass) RemoteAddress() string

Read remote address from request headers.

func (*ApiSessionClass) Request

func (apiSession *ApiSessionClass) Request() *http.Request

func (*ApiSessionClass) ResponseWriter

func (apiSession *ApiSessionClass) ResponseWriter() http.ResponseWriter

func (*ApiSessionClass) ScanParams

func (apiSession *ApiSessionClass) ScanParams(dest interface{}) error

func (*ApiSessionClass) SetApi added in v1.2.2

func (apiSession *ApiSessionClass) SetApi(api _interface.IApi)

func (*ApiSessionClass) SetClientType added in v1.2.2

func (apiSession *ApiSessionClass) SetClientType(clientType string)

func (*ApiSessionClass) SetData added in v1.2.2

func (apiSession *ApiSessionClass) SetData(key string, data interface{})

func (*ApiSessionClass) SetHeader

func (apiSession *ApiSessionClass) SetHeader(key string, value string)

Set header of response.

func (*ApiSessionClass) SetJwtBody added in v1.2.2

func (apiSession *ApiSessionClass) SetJwtBody(jwtBody map[string]interface{})

func (*ApiSessionClass) SetJwtHeaderName added in v1.2.2

func (apiSession *ApiSessionClass) SetJwtHeaderName(headerName string)

func (*ApiSessionClass) SetLang added in v1.2.2

func (apiSession *ApiSessionClass) SetLang(lang string)

func (*ApiSessionClass) SetOriginalParams added in v1.2.2

func (apiSession *ApiSessionClass) SetOriginalParams(originalParams map[string]interface{})

func (*ApiSessionClass) SetParams added in v1.2.2

func (apiSession *ApiSessionClass) SetParams(params map[string]interface{})

func (*ApiSessionClass) SetPathVars added in v1.2.2

func (apiSession *ApiSessionClass) SetPathVars(vars map[string]string)

func (*ApiSessionClass) SetRequest added in v1.2.2

func (apiSession *ApiSessionClass) SetRequest(r *http.Request)

func (*ApiSessionClass) SetResponseWriter added in v1.2.2

func (apiSession *ApiSessionClass) SetResponseWriter(w http.ResponseWriter)

func (*ApiSessionClass) SetStatusCode

func (apiSession *ApiSessionClass) SetStatusCode(code _type.StatusCode)

Set status code of response.

func (*ApiSessionClass) SetUserId added in v1.2.2

func (apiSession *ApiSessionClass) SetUserId(userId uint64)

func (*ApiSessionClass) UrlParams added in v1.2.2

func (apiSession *ApiSessionClass) UrlParams() map[string]string

Read url params from get request.

func (*ApiSessionClass) UserId

func (apiSession *ApiSessionClass) UserId() uint64

func (*ApiSessionClass) WriteJson

func (apiSession *ApiSessionClass) WriteJson(data interface{}) error

Response json body.

func (*ApiSessionClass) WriteText

func (apiSession *ApiSessionClass) WriteText(text string) error

Response text body.

type ContentTypeValue

type ContentTypeValue string
const (
	// ContentBinaryHeaderValue header value for binary data.
	ContentTypeValue_Binary ContentTypeValue = "application/octet-stream"
	// ContentHTMLHeaderValue is the  string of text/html response header's content type value.
	ContentTypeValue_HTML ContentTypeValue = "text/html; charset=UTF-8"
	// ContentJSONHeaderValue header value for JSON data.
	ContentTypeValue_JSON ContentTypeValue = "application/json; charset=UTF-8"
	// ContentJavascriptHeaderValue header value for JSONP & Javascript data.
	ContentTypeValue_Javascript ContentTypeValue = "application/javascript; charset=UTF-8"
	// ContentTextHeaderValue header value for Text data.
	ContentTypeValue_Text ContentTypeValue = "text/plain; charset=UTF-8"
	// ContentXMLHeaderValue header value for XML data.
	ContentTypeValue_XML ContentTypeValue = "text/xml; charset=UTF-8"
	// ContentMarkdownHeaderValue custom key/content type, the real is the text/html.
	ContentTypeValue_Markdown ContentTypeValue = "text/markdown; charset=UTF-8"
	// ContentYAMLHeaderValue header value for YAML data.
	ContentTypeValue_YAML ContentTypeValue = "application/x-yaml; charset=UTF-8"
)

type HeaderName

type HeaderName string
const (
	// ContentTypeHeaderKey is the header key of "Content-Type".
	HeaderName_ContentType HeaderName = "Content-Type"

	// LastModifiedHeaderKey is the header key of "Last-Modified".
	HeaderName_LastModified HeaderName = "Last-Modified"
	// IfModifiedSinceHeaderKey is the header key of "If-Modified-Since".
	HeaderName_IfModifiedSince HeaderName = "If-Modified-Since"
	// CacheControlHeaderKey is the header key of "Cache-Control".
	HeaderName_CacheControl HeaderName = "Cache-Control"
	// ETagHeaderKey is the header key of "ETag".
	HeaderName_ETag HeaderName = "ETag"

	// ContentDispositionHeaderKey is the header key of "Content-Disposition".
	HeaderName_ContentDisposition HeaderName = "Content-Disposition"
	// ContentLengthHeaderKey is the header key of "Content-Length"
	HeaderName_ContentLength HeaderName = "Content-Length"
	// ContentEncodingHeaderKey is the header key of "Content-Encoding".
	HeaderName_ContentEncoding HeaderName = "Content-Encoding"
	// GzipHeaderValue is the header value of "gzip".
	HeaderName_Gzip HeaderName = "gzip"
	// AcceptEncodingHeaderKey is the header key of "Accept-Encoding".
	HeaderName_AcceptEncoding HeaderName = "Accept-Encoding"
	// VaryHeaderKey is the header key of "Vary".
	HeaderName_Vary HeaderName = "Vary"
)

Directories

Path Synopsis
type module

Jump to

Keyboard shortcuts

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