Documentation ¶
Index ¶
- Constants
- Variables
- func CallForConuwa(ctx *Ctx, name string, path string, req, rsp interface{}) error
- func CallForGateway(ctx *Ctx, name string, path string, req []byte) ([]byte, error)
- func ConuwaStop(ctx *Ctx, name string) error
- func GetClient(u *url.URL) *fasthttp.HostClient
- func MustParseUrl(rawRul string) (u *url.URL)
- func RegisterInterface(infos ...[]*InterfaceInfo)
- type BaseRpcResp
- type Ctx
- func (p *Ctx) Context() *fasthttp.RequestCtx
- func (p *Ctx) Error(err error) error
- func (p *Ctx) GetReqHeader(key string) string
- func (p *Ctx) Json(i any) error
- func (p *Ctx) Method() string
- func (p *Ctx) Next() error
- func (p *Ctx) Path() string
- func (p *Ctx) RealIp() string
- func (p *Ctx) ReqBody() []byte
- func (p *Ctx) Role() string
- func (p *Ctx) RspBody() []byte
- func (p *Ctx) SendRaw(buf []byte) error
- func (p *Ctx) SetReqHeader(key string, value string)
- func (p *Ctx) SetRspHeader(key string, value string)
- type Handler
- type InterfaceInfo
- type Option
- type Route
- type Router
- type Service
- func (p *Service) AcquireCtx(c *fasthttp.RequestCtx) *Ctx
- func (p *Service) All(path string, handler Handler)
- func (p *Service) BindAddress() (addrs []string)
- func (p *Service) Copy(path string, handler Handler)
- func (p *Service) Delete(path string, handler Handler)
- func (p *Service) Get(path string, handler Handler)
- func (p *Service) GetPost(path string, handler Handler)
- func (p *Service) Head(path string, handler Handler)
- func (p *Service) Link(path string, handler Handler)
- func (p *Service) ListenAndServe() (err error)
- func (p *Service) Lock(path string, handler Handler)
- func (p *Service) Option(opts ...*Option) *Service
- func (p *Service) Options(path string, handler Handler)
- func (p *Service) Patch(path string, handler Handler)
- func (p *Service) Post(path string, handler Handler)
- func (p *Service) Propfind(path string, handler Handler)
- func (p *Service) Purge(path string, handler Handler)
- func (p *Service) Put(path string, handler Handler)
- func (p *Service) ReleaseCtx(ctx *Ctx)
- func (p *Service) Unlink(path string, handler Handler)
- func (p *Service) Unlock(path string, handler Handler)
- func (p *Service) Use(i ...any)
- func (p *Service) View(path string, handler Handler)
- type ServiceInfo
- type TypeJsonTag
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 DefaultMethods = []string{ MethodGet, MethodPost, MethodPut, MethodPatch, MethodDelete, MethodCopy, MethodHead, MethodOptions, MethodLink, MethodUnlink, MethodPurge, MethodLock, MethodUnlock, MethodPropfind, MethodView, }
View Source
var DefaultService = NewService()
View Source
var Meta meta
Functions ¶
func CallForConuwa ¶
func CallForGateway ¶
func ConuwaStop ¶
func MustParseUrl ¶
func RegisterInterface ¶
func RegisterInterface(infos ...[]*InterfaceInfo)
Types ¶
type BaseRpcResp ¶
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
func (*Ctx) Context ¶
func (p *Ctx) Context() *fasthttp.RequestCtx
func (*Ctx) GetReqHeader ¶
func (*Ctx) SetReqHeader ¶
func (*Ctx) SetRspHeader ¶
type Handler ¶
func GenHandler ¶
type InterfaceInfo ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func OnShutdown ¶
func OnShutdown(logic ...func()) *Service
func WithServiceName ¶
func (*Service) AcquireCtx ¶
func (p *Service) AcquireCtx(c *fasthttp.RequestCtx) *Ctx
func (*Service) BindAddress ¶
func (*Service) ListenAndServe ¶
func (*Service) ReleaseCtx ¶
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)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.