Documentation
¶
Index ¶
- Variables
- func GuessCurrentAppURL(ctx context.Context) string
- func GuessCurrentHostDomain(ctx context.Context) string
- func GuessCurrentHostURL(ctx context.Context) string
- func IsCurrentGiteaSiteURL(ctx context.Context, s string) bool
- func IsRelativeURL(s string) bool
- func MakeAbsoluteURL(ctx context.Context, link string) string
- func ServeContentByReadSeeker(r *http.Request, w http.ResponseWriter, modTime *time.Time, ...)
- func ServeContentByReader(r *http.Request, w http.ResponseWriter, size int64, reader io.Reader, ...)
- func ServeSetHeaders(w http.ResponseWriter, opts *ServeHeaderOptions)
- func TimeoutDialer(cTimeout time.Duration) func(ctx context.Context, net, addr string) (c net.Conn, err error)
- type GiteaSiteURL
- type Request
- func (r *Request) Body(data any) *Request
- func (r *Request) GoString() string
- func (r *Request) Header(key, value string) *Request
- func (r *Request) Param(key, value string) *Request
- func (r *Request) Response() (*http.Response, error)
- func (r *Request) SetContext(ctx context.Context) *Request
- func (r *Request) SetReadWriteTimeout(readWriteTimeout time.Duration) *Request
- func (r *Request) SetTLSClientConfig(config *tls.Config) *Request
- func (r *Request) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *Request
- func (r *Request) SetTransport(transport http.RoundTripper) *Request
- type RequestContextKeyStruct
- type ServeHeaderOptions
- type Settings
Constants ¶
This section is empty.
Variables ¶
var RequestContextKey = RequestContextKeyStruct{}
Functions ¶
func GuessCurrentAppURL ¶ added in v1.22.0
GuessCurrentAppURL tries to guess the current full public URL (with sub-path) by http headers. It always has a '/' suffix, exactly the same as setting.AppURL TODO: should rename it to GuessCurrentPublicURL in the future
func GuessCurrentHostDomain ¶
func GuessCurrentHostURL ¶ added in v1.22.1
GuessCurrentHostURL tries to guess the current full host URL (no sub-path) by http headers, there is no trailing slash.
func IsCurrentGiteaSiteURL ¶ added in v1.22.0
func IsRelativeURL ¶ added in v1.22.0
IsRelativeURL detects if a URL is relative (no scheme or host)
func MakeAbsoluteURL ¶ added in v1.22.0
MakeAbsoluteURL tries to make a link to an absolute public URL: * If link is empty, it returns the current public URL. * If link is absolute, it returns the link. * Otherwise, it returns the current host URL + link, the link itself should have correct sub-path (AppSubURL) if needed.
func ServeContentByReadSeeker ¶ added in v1.20.0
func ServeContentByReadSeeker(r *http.Request, w http.ResponseWriter, modTime *time.Time, reader io.ReadSeeker, opts *ServeHeaderOptions)
func ServeContentByReader ¶ added in v1.20.0
func ServeContentByReader(r *http.Request, w http.ResponseWriter, size int64, reader io.Reader, opts *ServeHeaderOptions)
func ServeSetHeaders ¶ added in v1.20.0
func ServeSetHeaders(w http.ResponseWriter, opts *ServeHeaderOptions)
ServeSetHeaders sets necessary content serve headers
Types ¶
type GiteaSiteURL ¶
func ParseGiteaSiteURL ¶
func ParseGiteaSiteURL(ctx context.Context, s string) *GiteaSiteURL
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request provides more useful methods for requesting one url than http.Request.
func NewRequest ¶ added in v1.2.0
NewRequest returns *Request with specific method
func (*Request) Body ¶
Body adds request raw body. It supports string, []byte and io.Reader as body.
func (*Request) Param ¶
Param adds query param in to request. params build query string as ?key1=value1&key2=value2...
func (*Request) Response ¶
Response executes request client gets response manually. Caller MUST close the response body if no error occurs
func (*Request) SetContext ¶ added in v1.15.0
SetContext sets the request's Context
func (*Request) SetReadWriteTimeout ¶ added in v1.20.0
func (*Request) SetTLSClientConfig ¶
SetTLSClientConfig sets tls connection configurations if visiting https url.
func (*Request) SetTimeout ¶
SetTimeout sets connect time out and read-write time out for BeegoRequest.
func (*Request) SetTransport ¶
func (r *Request) SetTransport(transport http.RoundTripper) *Request
SetTransport sets transport to
type RequestContextKeyStruct ¶ added in v1.22.0
type RequestContextKeyStruct struct{}
type ServeHeaderOptions ¶ added in v1.20.0
type ServeHeaderOptions struct { ContentType string // defaults to "application/octet-stream" ContentTypeCharset string ContentLength *int64 Disposition string // defaults to "attachment" Filename string CacheIsPublic bool CacheDuration time.Duration // defaults to 5 minutes LastModified time.Time }