rpc

package module
v0.0.0-...-addaa65 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: AGPL-3.0 Imports: 22 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

rpc

Documentation

Index

Constants

View Source
const (
	MethodGet      = "GET"      // RFC 7231, 4.3.1
	MethodPost     = "POST"     // RFC 7231, 4.3.3
	MethodPut      = "PUT"      // RFC 7231, 4.3.4
	MethodPatch    = "PATCH"    // RFC 5789, 2.2
	MethodDelete   = "DELETE"   // RFC 7231, 4.3.5
	MethodCopy     = "COPY"     // RFC 4918, 11.1
	MethodHead     = "HEAD"     // RFC 7231, 4.3.2
	MethodOptions  = "OPTIONS"  // RFC 7231, 4.3.7
	MethodLink     = "LINK"     // RFC 2068,
	MethodUnlink   = "UNLINK"   // RFC 2068,
	MethodPurge    = "PURGE"    // HTTP 1.1, 9.2
	MethodLock     = "LOCK"     // RFC 4918, 11.2
	MethodUnlock   = "UNLOCK"   // RFC 4918, 11.3
	MethodPropfind = "PROPFIND" // RFC 4918, 11.1
	MethodView     = "VIEW"     // RFC 5842, 7.1

)
View Source
const (
	HeaderAccept     = "Accept"
	HeaderAcceptEnc  = "Accept-Encoding"
	HeaderAcceptLang = "Accept-Language"

	HeaderCacheControl = "Cache-Control"
	HeaderConnection   = "Connection"
	HeaderContentEnc   = "Content-Encoding"
	HeaderContentLang  = "Content-Language"
	HeaderContentLen   = "Content-Length"
	HeaderContentLoc   = "Content-Location"
	HeaderContentMD5   = "Content-MD5"
	HeaderContentType  = "Content-Type"

	HeaderDate = "Date"

	HeaderETag    = "ETag"
	HeaderExpect  = "Expect"
	HeaderExpires = "Expires"

	HeaderFrom = "From"

	HeaderHost = "Host"

	HeaderIfMatch           = "If-Match"
	HeaderIfModifiedSince   = "If-Modified-Since"
	HeaderIfNoneMatch       = "If-None-Match"
	HeaderIfRange           = "If-Range"
	HeaderIfUnmodifiedSince = "If-Unmodified-Since"

	HeaderLastModified = "Last-Modified"
	HeaderLocation     = "Location"

	HeaderMaxForwards = "Max-Forwards"

	HeaderPragma = "Pragma"

	HeaderRange = "Range"

	HeaderReferer = "Referer"

	HeaderTE = "TE"

	HeaderUpgrade   = "Upgrade"
	HeaderUserAgent = "User-Agent"

	HeaderXForwardedFor   = "X-Forwarded-For"
	HeaderXRealIP         = "X-Real-IP"
	HeaderXRequestID      = "X-Request-ID"
	HeaderXRequestedWith  = "X-Requested-With"
	HeaderXRequestedBy    = "X-Requested-By"
	HeaderXRequestedFor   = "X-Requested-For"
	HeaderXRequestedIn    = "X-Requested-In"
	HeaderXRequestedAt    = "X-Requested-At"
	HeaderXRequestedOn    = "X-Requested-On"
	HeaderXRequestedFrom  = "X-Requested-From"
	HeaderXRequestedVia   = "X-Requested-Via"
	HeaderXRequestedHost  = "X-Requested-Host"
	HeaderXRequestedURI   = "X-Requested-URI"
	HeaderXRequestedURL   = "X-Requested-URL"
	HeaderXRequestedPath  = "X-Requested-Path"
	HeaderXRequestedFile  = "X-Requested-File"
	HeaderXRequestedExt   = "X-Requested-Ext"
	HeaderXRequestedPort  = "X-Requested-Port"
	HeaderXRequestedProto = "X-Requested-Proto"

	HeaderSessionId = "X-Session-Id"
	HeaderRole      = "X-Role"
)

header

View Source
const (
	MIMEAbiWord         = "application/x-abiword"                                                     // .abw
	MIMEFreearc         = "application/x-freearc"                                                     // .arc
	MIMEXhtml           = "application/xhtml+xml"                                                     // .xhtml
	MIMEExcel           = "application/vnd.ms-excel"                                                  // .xls
	MIMEExcelXlsx       = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"         // .xlsx
	MIMEXml             = "application/xml"                                                           // .xml
	MIMEXul             = "application/vnd.mozilla.xul+xml"                                           // .xul
	MIMEZip             = "application/zip"                                                           // .zip
	MIMEPdf             = "application/pdf"                                                           // .pdf
	MIMEApplicationPhp  = "application/x-httpd-php"                                                   // .php
	MIMEApplicationPpt  = "application/vnd.ms-powerpoint"                                             // .ppt
	MIMEApplicationPptx = "application/vnd.openxmlformats-officedocument.presentationml.presentation" // .ppt
	MIMERar             = "application/vnd.rar"                                                       // .rar
	MIMERtf             = "application/rtf"                                                           // .rtf
	MIMESh              = "application/x-sh"                                                          // .sh
	MIMEApplication     = "application/vnd.apple.installer+xml"                                       // .mpkg
	MIMEOpenDoc         = "application/vnd.oasis.opendocument.presentation"                           // .odp
	MIMEOpenExcel       = "application/vnd.oasis.opendocument.spreadsheet"                            // .ods
	MIMEOpenText        = "application/vnd.oasis.opendocument.text"                                   // .odt
	MIMEMsword          = "application/msword"                                                        // .doc
	MIMEWord            = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"   // .docx
	MIMENsOpenTypeFont  = "application/vnd.ms-fontobject"                                             // .eot
	MIMEEpub            = "application/epub+zip"                                                      // .epub
	MIMEGzip            = "application/gzip"                                                          // .gz
	MIMEJavaArchive     = "application/java-archive"                                                  // .jar
	MIMEJson            = "application/json"                                                          // .json
	MIMEJsonLD          = "application/ld+json"                                                       // .jsonld
	MIMEApplicationOgg  = "application/ogg"                                                           // .ogx
	MIMETar             = "application/x-tar"                                                         // .tar
	MIMEMsVisio         = "application/vnd.visio"                                                     // .vsd
	MIMEBzip            = "application/x-bzip"                                                        // .bz
	MIMEBzip2           = "application/x-bzip2"                                                       // .bz2
	MIMECdf             = "application/x-cdf"                                                         // .cdf
	MIMECsh             = "application/x-csh"                                                         // .csh
	MIMEAmazonEbook     = "application/vnd.amazon.ebook"                                              // .azw
	MIMEBinary          = "application/octet-stream"                                                  // .bin

	MIMEAudioAac  = "audio/aac"   // .aac
	MIMEAudioFlac = "audio/flac"  // .flac
	MIMEAudioM4a  = "audio/x-m4a" // .m4a
	MIMEAudioMidi = "audio/midi"  // .midi .mid
	MIMEAudioOgg  = "audio/ogg"   // .oga
	MIMEAudioOpus = "audio/opus"  // .opus
	MIMEAudioMpeg = "audio/mpeg"  // .mp3
	MIMEAudioWav  = "audio/wav"   // .wav
	MIMEAudioWebm = "audio/webm"  // .weba
	MIMEAudio3gpp = "audio/3gpp"  // .3gp

	MIMEImageAVIF = "image/avif"               // .avif
	MIMEImageBmp  = "image/bmp"                // .bmp
	MIMEImageGif  = "image/gif"                // .gif
	MIMEImageIco  = "image/vnd.microsoft.icon" // .ico
	MIMEImageJpeg = "image/jpeg"               // .jpeg .jpg
	MIMEImagePng  = "image/png"                // .png
	MIMEImageApng = "image/apng"               // .apng
	MIMEImageSvg  = "image/svg+xml"            // .svg
	MIMEImageTiff = "image/tiff"               // .tiff .tif
	MIMEImageWebp = "image/webp"               // .webp
	MIMEImageJp2  = "image/jp2"                // .jp2
	MIMEImageJpx  = "image/jpx"                // .jpx
	MIMEImageJpm  = "image/jpm"                // .jpm
	MIMEImageMj2  = "image/mj2"                // .mj2

	MIMEMsVideo    = "video/x-msvideo"  // .avi
	MIMEVideo3gpp  = "video/3gpp"       // .3gp
	MIMEVideo3gpp2 = "video/3gpp2"      // .3g2
	MIMEVideoH261  = "video/h261"       // .h261
	MIMEVideoH263  = "video/h263"       // .h263
	MIMEVideoH264  = "video/h264"       // .h264
	MIMEVideoMpeg  = "video/mpeg"       // .mpeg
	MIMEVideoOgg   = "video/ogg"        // .ogv
	MIMEVideoMp2t  = "video/mp2t"       // .ts
	MIMEVideoWebm  = "video/webm"       // .webm
	MIMEVideoMp4   = "video/mp4"        // .mp4
	MIMEVideoM4v   = "video/x-m4v"      // .m4v
	MIMEVideoMj2   = "video/mj2"        // .mj2
	MIMEVideoMkv   = "video/x-matroska" // .mkv
	MIMEVideoMov   = "video/quicktime"  // .mov
	MIMEVideoMxf   = "video/mxf"        // .mxf
	MIMEVideoFlv   = "video/x-flv"      // .flv
	MIMEVideoF4v   = "video/x-f4v"      // .f4v
	MIMEVideoF4p   = "video/x-f4p"      // .f4p
	MIMEVideoF4a   = "video/x-f4a"      // .f4a
	MIMEVideoF4b   = "video/x-f4b"      // .f4b
	MIMEVideoMng   = "video/x-mng"      // .mng
	MIMEVideoAsf   = "video/x-ms-asf"   // .asf
	MIMEVideoWmv   = "video/x-ms-wmv"   // .wmv
	MIMEVideoWmx   = "video/x-ms-wmx"   // .wmx
	MIMEVideoWvx   = "video/x-ms-wvx"   // .wvx
	MIMEVideoM2v   = "video/x-matroska" // .m2v

	MIMETextCss      = "text/css"        // .css
	MIMETextCsv      = "text/csv"        // .csv
	MIMETextHtml     = "text/html"       // .html .htm
	MIMETextCalendar = "text/calendar"   // .ics
	MIMEJavaScript   = "text/javascript" // .js
	MIMEJsModule     = "text/javascript" // .mjs
	MIMETextMarkdown = "text/markdown"   // .md
	MIMETextPlain    = "text/plain"      // .txt
	MIMETextRtf      = "text/rtf"        // .rtf
	MIMETextVcard    = "text/vcard"      // .vcf
	MIMETextXml      = "text/xml"        // .xml

	MIMEFontOtf   = "font/otf"   // .otf
	MIMEFontTtf   = "font/ttf"   // .ttf
	MIMEFontWoff  = "font/woff"  // .woff
	MIMEFontWoff2 = "font/woff2" // .woff2

	MIMEConuwaJson = "conuwa/json;charset=utf-8"
)

MIME types for HTTP requests. See https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Type

Variables

View Source
var DefaultService = NewService()
View Source
var Meta meta

Functions

func CallForConuwa

func CallForConuwa(ctx *Ctx, name string, path string, req, rsp interface{}) error

func CallForGateway

func CallForGateway(ctx *Ctx, name string, path string, req []byte) ([]byte, error)

func ConuwaStop

func ConuwaStop(ctx *Ctx, name string) error

func GetClient

func GetClient(u *url.URL) *fasthttp.HostClient

func MustParseUrl

func MustParseUrl(rawRul string) (u *url.URL)

func RegisterInterface

func RegisterInterface(infos ...[]*InterfaceInfo)

Types

type BaseRpcResp

type BaseRpcResp struct {
	conuwa.Error
	Data any `json:"data,omitempty" yaml:"data,omitempty"`
}

type Ctx

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

func NewCtx

func NewCtx() *Ctx

func (*Ctx) Context

func (p *Ctx) Context() *fasthttp.RequestCtx

func (*Ctx) Error

func (p *Ctx) Error(err error) error

func (*Ctx) GetReqHeader

func (p *Ctx) GetReqHeader(key string) string

func (*Ctx) Json

func (p *Ctx) Json(i any) error

func (*Ctx) Method

func (p *Ctx) Method() string

func (*Ctx) Next

func (p *Ctx) Next() error

func (*Ctx) Path

func (p *Ctx) Path() string

func (*Ctx) RealIp

func (p *Ctx) RealIp() string

func (*Ctx) ReqBody

func (p *Ctx) ReqBody() []byte

func (*Ctx) Role

func (p *Ctx) Role() string

func (*Ctx) RspBody

func (p *Ctx) RspBody() []byte

func (*Ctx) SendRaw

func (p *Ctx) SendRaw(buf []byte) error

SendRaw send raw data to client

func (*Ctx) SetReqHeader

func (p *Ctx) SetReqHeader(key string, value string)

func (*Ctx) SetRspHeader

func (p *Ctx) SetRspHeader(key string, value string)

type Handler

type Handler = func(ctx *Ctx) error

func GenHandler

func GenHandler(logic any) Handler

type InterfaceInfo

type InterfaceInfo struct {
	Method  string      `json:"method,omitempty" yaml:"method,omitempty"`
	Path    string      `json:"path,omitempty" yaml:"path,omitempty"`
	Handler interface{} `json:"handler,omitempty" yaml:"handler,omitempty"`
}

type Option

type Option struct {
	ServiceName string

	OnShutdown []func()

	Port string
}

type Route

type Route struct {
	Path    string
	Handler Handler
	// contains filtered or unexported fields
}

type Router

type Router interface {
}

type Service

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

func NewService

func NewService(opts ...*Option) *Service

func OnShutdown

func OnShutdown(logic ...func()) *Service

func WithPort

func WithPort(port string) *Service

func WithServiceName

func WithServiceName(name string) *Service

func (*Service) AcquireCtx

func (p *Service) AcquireCtx(c *fasthttp.RequestCtx) *Ctx

func (*Service) All

func (p *Service) All(path string, handler Handler)

func (*Service) BindAddress

func (p *Service) BindAddress() (addrs []string)

func (*Service) Copy

func (p *Service) Copy(path string, handler Handler)

func (*Service) Delete

func (p *Service) Delete(path string, handler Handler)

func (*Service) Get

func (p *Service) Get(path string, handler Handler)

func (*Service) GetPost

func (p *Service) GetPost(path string, handler Handler)

func (*Service) Head

func (p *Service) Head(path string, handler Handler)
func (p *Service) Link(path string, handler Handler)

func (*Service) ListenAndServe

func (p *Service) ListenAndServe() (err error)

func (*Service) Lock

func (p *Service) Lock(path string, handler Handler)

func (*Service) Option

func (p *Service) Option(opts ...*Option) *Service

func (*Service) Options

func (p *Service) Options(path string, handler Handler)

func (*Service) Patch

func (p *Service) Patch(path string, handler Handler)

func (*Service) Post

func (p *Service) Post(path string, handler Handler)

func (*Service) Propfind

func (p *Service) Propfind(path string, handler Handler)

func (*Service) Purge

func (p *Service) Purge(path string, handler Handler)

func (*Service) Put

func (p *Service) Put(path string, handler Handler)

func (*Service) ReleaseCtx

func (p *Service) ReleaseCtx(ctx *Ctx)
func (p *Service) Unlink(path string, handler Handler)

func (*Service) Unlock

func (p *Service) Unlock(path string, handler Handler)

func (*Service) Use

func (p *Service) Use(i ...any)

func (*Service) View

func (p *Service) View(path string, handler Handler)

type ServiceInfo

type ServiceInfo struct {
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
}

type TypeJsonTag

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

func GetTypeJsonTag

func GetTypeJsonTag(value reflect.Value) *TypeJsonTag

func NewTypeJsonTag

func NewTypeJsonTag() *TypeJsonTag

func (*TypeJsonTag) Get

func (p *TypeJsonTag) Get(key string) *reflect.StructField

func (*TypeJsonTag) Set

func (p *TypeJsonTag) Set(key string, value *reflect.StructField)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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