api_session

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

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

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

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

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

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

	StatusCode_InternalServerError           t_core.StatusCode = 500 // RFC 7231, 6.6.1
	StatusCode_NotImplemented                t_core.StatusCode = 501 // RFC 7231, 6.6.2
	StatusCode_BadGateway                    t_core.StatusCode = 502 // RFC 7231, 6.6.3
	StatusCode_ServiceUnavailable            t_core.StatusCode = 503 // RFC 7231, 6.6.4
	StatusCode_GatewayTimeout                t_core.StatusCode = 504 // RFC 7231, 6.6.5
	StatusCode_HTTPVersionNotSupported       t_core.StatusCode = 505 // RFC 7231, 6.6.6
	StatusCode_VariantAlsoNegotiates         t_core.StatusCode = 506 // RFC 2295, 8.1
	StatusCode_InsufficientStorage           t_core.StatusCode = 507 // RFC 4918, 11.5
	StatusCode_LoopDetected                  t_core.StatusCode = 508 // RFC 5842, 7.2
	StatusCode_NotExtended                   t_core.StatusCode = 510 // RFC 2774, 7
	StatusCode_NetworkAuthenticationRequired t_core.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 ApiSessionType added in v1.4.1

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

func NewApiSession

func NewApiSession() *ApiSessionType

func (*ApiSessionType) AddDefer added in v1.4.1

func (apiSession *ApiSessionType) AddDefer(defer_ func())

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

func (*ApiSessionType) Api added in v1.4.1

func (apiSession *ApiSessionType) Api() i_core.IApi

func (*ApiSessionType) Body added in v1.4.1

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

Get request body.

func (*ApiSessionType) ClientType added in v1.4.1

func (apiSession *ApiSessionType) ClientType() string

func (*ApiSessionType) Data added in v1.4.1

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

func (*ApiSessionType) Defers added in v1.4.1

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

func (*ApiSessionType) FormValues added in v1.4.1

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

Read form data from request.

func (*ApiSessionType) Header added in v1.4.1

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

Read header by key from request headers.

func (*ApiSessionType) Host added in v1.4.1

func (apiSession *ApiSessionType) Host() string

Get request host.

func (*ApiSessionType) JwtBody added in v1.4.1

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

func (*ApiSessionType) JwtHeaderName added in v1.4.1

func (apiSession *ApiSessionType) JwtHeaderName() string

func (*ApiSessionType) Lang added in v1.4.1

func (apiSession *ApiSessionType) Lang() string

func (*ApiSessionType) Logger added in v1.4.1

func (apiSession *ApiSessionType) Logger() i_logger.ILogger

func (*ApiSessionType) Method added in v1.4.1

func (apiSession *ApiSessionType) Method() string

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

func (*ApiSessionType) MustScanParams added in v1.4.1

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

func (*ApiSessionType) OriginalParams added in v1.4.1

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

func (*ApiSessionType) Params added in v1.4.1

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

func (*ApiSessionType) Path added in v1.4.1

func (apiSession *ApiSessionType) Path() string

Get request path.

func (*ApiSessionType) PathVars added in v1.4.1

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

func (*ApiSessionType) ReadJSON added in v1.4.1

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

Read json data from request body.

func (*ApiSessionType) ReadMap added in v1.5.3

func (apiSession *ApiSessionType) ReadMap() (map[string]interface{}, error)

func (*ApiSessionType) Redirect added in v1.4.1

func (apiSession *ApiSessionType) Redirect(url string)

func (*ApiSessionType) RemoteAddress added in v1.4.1

func (apiSession *ApiSessionType) RemoteAddress() string

Read remote address from request headers.

func (*ApiSessionType) Request added in v1.4.1

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

func (*ApiSessionType) ResponseWriter added in v1.4.1

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

func (*ApiSessionType) ScanParams added in v1.4.1

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

func (*ApiSessionType) SetApi added in v1.4.1

func (apiSession *ApiSessionType) SetApi(api i_core.IApi)

func (*ApiSessionType) SetClientType added in v1.4.1

func (apiSession *ApiSessionType) SetClientType(clientType string)

func (*ApiSessionType) SetData added in v1.4.1

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

func (*ApiSessionType) SetHeader added in v1.4.1

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

Set header of response.

func (*ApiSessionType) SetJwtBody added in v1.4.1

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

func (*ApiSessionType) SetJwtHeaderName added in v1.4.1

func (apiSession *ApiSessionType) SetJwtHeaderName(headerName string)

func (*ApiSessionType) SetLang added in v1.4.1

func (apiSession *ApiSessionType) SetLang(lang string)

func (*ApiSessionType) SetOriginalParams added in v1.4.1

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

func (*ApiSessionType) SetParams added in v1.4.1

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

func (*ApiSessionType) SetPathVars added in v1.4.1

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

func (*ApiSessionType) SetRequest added in v1.4.1

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

func (*ApiSessionType) SetResponseWriter added in v1.4.1

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

func (*ApiSessionType) SetStatusCode added in v1.4.1

func (apiSession *ApiSessionType) SetStatusCode(code t_core.StatusCode)

Set status code of response.

func (*ApiSessionType) SetUserId added in v1.4.1

func (apiSession *ApiSessionType) SetUserId(userId uint64)

func (*ApiSessionType) UrlParams added in v1.4.1

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

Read url params from get request.

func (*ApiSessionType) UserId added in v1.4.1

func (apiSession *ApiSessionType) UserId() uint64

func (*ApiSessionType) WriteJson added in v1.4.1

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

Response json body.

func (*ApiSessionType) WriteText added in v1.4.1

func (apiSession *ApiSessionType) 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