apimodels

package
v0.0.0-...-76e4eaa Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package apimodels provides models for HTTP api

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIContext

type APIContext struct {
	Configuration *configuration.APIConfiguration
	Trazability   Trazability
	Request       Request
	Response      Response
	Database      *sql.DB
}

type Endpoint

type Endpoint struct {
	Path   string     `json:"path,omitempty"`
	Method HTTPMethod `json:"method,omitempty"`

	RequestMimeType  MimeType `json:"requestMimeType,omitempty"`
	ResponseMimeType MimeType `json:"responseMimeType,omitempty"`

	Listener EndpointListener `json:"-"`

	IsMultipartForm bool `json:"containsFiles,omitempty"`
	Secured         bool `json:"secured,omitempty"`
	Database        bool `json:"-"`
}

type EndpointListener

type EndpointListener func(context *APIContext) (*Response, *verrors.APIError)

type HTTPHeaders

type HTTPHeaders string
const (
	HeaderContentType             HTTPHeaders = "Content-Type"
	HeaderAccept                  HTTPHeaders = "Accept"
	HeaderAuthorization           HTTPHeaders = "Authorization"
	HeaderUserAgent               HTTPHeaders = "User-Agent"
	HeaderContentLength           HTTPHeaders = "Content-Length"
	HeaderContentEncoding         HTTPHeaders = "Content-Encoding"
	HeaderContentDisposition      HTTPHeaders = "Content-Disposition"
	HeaderContentTransferEncoding HTTPHeaders = "Content-Transfer-Encoding"
	HeaderContentLanguage         HTTPHeaders = "Content-Language"
)

type HTTPMethod

type HTTPMethod int
const (
	GetMethod HTTPMethod = iota
	PostMethod
	PutMethod
	DeleteMethod
	PatchMethod
	OptionsMethod
	HeadMethod
	TraceMethod
)

type MimeType

type MimeType string
const (
	MimeApplicationJSON        MimeType = "application/json"
	MimeApplicationXML         MimeType = "application/xml"
	MimeApplicationYaml        MimeType = "application/yaml"
	MimeApplicationForm        MimeType = "application/x-www-form-urlencoded"
	MimeApplicationOctetStream MimeType = "application/octet-stream"
	MimeTextPlain              MimeType = "text/plain"
	MimeTextHTML               MimeType = "text/html"
)

type Request

type Request struct {
	Authorization string                             `json:"authorization,omitempty"`
	IP            string                             `json:"ip,omitempty"`
	UserAgent     string                             `json:"userAgent,omitempty"`
	Params        map[string]string                  `json:"params,omitempty"`
	Body          any                                `json:"body,omitempty"`
	Headers       map[string]string                  `json:"headers,omitempty"`
	Files         map[string][]*multipart.FileHeader `json:"files,omitempty"`
}

func (Request) GetFile

func (r Request) GetFile(name string, maxFileSize int64) (*multipart.FileHeader, error)

func (Request) GetParamInt64

func (r Request) GetParamInt64(name string) (*int64, error)

type Response

type Response struct {
	Code         int         `json:"-"`
	Response     interface{} `json:"response,omitempty"`
	ResponseTime int64       `json:"response_time,omitempty"`
}

type Trazability

type Trazability struct {
	Endpoint  Endpoint `json:"endpoint"`
	Timestamp *int64   `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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