* add: generic cache random time offset expired. * bugfix: Csrf token should be Secure and httpOnly, but not now * fix: expose the Offset property to allow external modifications * improving the concurrency performance of random value calculation * add WithOffsetFunc to define private RandomExpireCache.offset field * fix: add seconds definition * build(deps): bump github.com/stretchr/testify from 1.7.1 to 1.8.0 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.1 to 1.8.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.7.1...v1.8.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix 4907: force admin service http only * Feat: add get all tasks function (#4999) * feat: add get all tasks function * Refine Comments : admin/profile.go,bean/mock.go,config/global.go... (#5009) * Refine Comments * refine comments for cache.go * refine comments for log.go * Update orm.go * refine comments for orm_log.go,types.go * Update utils.go * Update doc.go * refine comments for for four files (#5011) * refine comments for cache.go * refine comments for log.go * Update orm.go * refine comments for orm_log.go,types.go * Update utils.go * Update doc.go * Update db.go * fix pass []any as any in variadic function by asasalint (#5012) * fix pass []any as any in variadic function * add change log * build(deps): bump go.opentelemetry.io/otel/trace from 1.7.0 to 1.8.0 (#5019) Bumps [go.opentelemetry.io/otel/trace](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel/trace dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * refine comments for package core (#5014) * Refine Comments * refine comments for cache.go * refine comments for log.go * Update orm.go * refine comments for orm_log.go,types.go * Update utils.go * Update doc.go * refine comments * refine comments * Update db.go * refine comments for core * build(deps): bump go.opentelemetry.io/otel/exporters/stdout/stdouttrace (#5018) Bumps [go.opentelemetry.io/otel/exporters/stdout/stdouttrace](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel/exporters/stdout/stdouttrace dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix 5022: Miss assiging ln to graceful Server (#5028) * prepare for releasing v2.0.5 (#5032) Co-authored-by: auual <ding@ibyte.me> Co-authored-by: Leon Ding <deen.job@qq.com> Co-authored-by: dada0z <zhang.guangda@qq.com> Co-authored-by: kevinzeng <kevinzeng@zego.im> Co-authored-by: Kevin Tsang <39397413+ktalg@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 日暮颂歌1991 <448081525@qq.com> Co-authored-by: Regan Yue <1131625869@qq.com> Co-authored-by: alingse <alingse@foxmail.com>
		
			
				
	
	
		
			155 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			155 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2014 beego Author. All Rights Reserved.
 | ||
| //
 | ||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||
| // you may not use this file except in compliance with the License.
 | ||
| // You may obtain a copy of the License at
 | ||
| //
 | ||
| //      http://www.apache.org/licenses/LICENSE-2.0
 | ||
| //
 | ||
| // Unless required by applicable law or agreed to in writing, software
 | ||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||
| // See the License for the specific language governing permissions and
 | ||
| // limitations under the License.
 | ||
| 
 | ||
| package context
 | ||
| 
 | ||
| import (
 | ||
| 	"github.com/beego/beego/v2/server/web/context"
 | ||
| )
 | ||
| 
 | ||
| // BeegoOutput does work for sending response header.
 | ||
| type BeegoOutput context.BeegoOutput
 | ||
| 
 | ||
| // NewOutput returns new BeegoOutput.
 | ||
| // it contains nothing now.
 | ||
| func NewOutput() *BeegoOutput {
 | ||
| 	return (*BeegoOutput)(context.NewOutput())
 | ||
| }
 | ||
| 
 | ||
| // Reset init BeegoOutput
 | ||
| func (output *BeegoOutput) Reset(ctx *Context) {
 | ||
| 	(*context.BeegoOutput)(output).Reset((*context.Context)(ctx))
 | ||
| }
 | ||
| 
 | ||
| // Header sets response header item string via given key.
 | ||
| func (output *BeegoOutput) Header(key, val string) {
 | ||
| 	(*context.BeegoOutput)(output).Header(key, val)
 | ||
| }
 | ||
| 
 | ||
| // Body sets response body content.
 | ||
| // if EnableGzip, compress content string.
 | ||
| // it sends out response body directly.
 | ||
| func (output *BeegoOutput) Body(content []byte) error {
 | ||
| 	return (*context.BeegoOutput)(output).Body(content)
 | ||
| }
 | ||
| 
 | ||
| // Cookie sets cookie value via given key.
 | ||
| // others are ordered as cookie's max age time, path,domain, secure and httponly.
 | ||
| func (output *BeegoOutput) Cookie(name string, value string, others ...interface{}) {
 | ||
| 	(*context.BeegoOutput)(output).Cookie(name, value, others...)
 | ||
| }
 | ||
| 
 | ||
| // JSON writes json to response body.
 | ||
| // if encoding is true, it converts utf-8 to \u0000 type.
 | ||
| func (output *BeegoOutput) JSON(data interface{}, hasIndent bool, encoding bool) error {
 | ||
| 	return (*context.BeegoOutput)(output).JSON(data, hasIndent, encoding)
 | ||
| }
 | ||
| 
 | ||
| // YAML writes yaml to response body.
 | ||
| func (output *BeegoOutput) YAML(data interface{}) error {
 | ||
| 	return (*context.BeegoOutput)(output).YAML(data)
 | ||
| }
 | ||
| 
 | ||
| // JSONP writes jsonp to response body.
 | ||
| func (output *BeegoOutput) JSONP(data interface{}, hasIndent bool) error {
 | ||
| 	return (*context.BeegoOutput)(output).JSONP(data, hasIndent)
 | ||
| }
 | ||
| 
 | ||
| // XML writes xml string to response body.
 | ||
| func (output *BeegoOutput) XML(data interface{}, hasIndent bool) error {
 | ||
| 	return (*context.BeegoOutput)(output).XML(data, hasIndent)
 | ||
| }
 | ||
| 
 | ||
| // ServeFormatted serve YAML, XML OR JSON, depending on the value of the Accept header
 | ||
| func (output *BeegoOutput) ServeFormatted(data interface{}, hasIndent bool, hasEncode ...bool) {
 | ||
| 	(*context.BeegoOutput)(output).ServeFormatted(data, hasIndent, hasEncode...)
 | ||
| }
 | ||
| 
 | ||
| // Download forces response for download file.
 | ||
| // it prepares the download response header automatically.
 | ||
| func (output *BeegoOutput) Download(file string, filename ...string) {
 | ||
| 	(*context.BeegoOutput)(output).Download(file, filename...)
 | ||
| }
 | ||
| 
 | ||
| // ContentType sets the content type from ext string.
 | ||
| // MIME type is given in mime package.
 | ||
| func (output *BeegoOutput) ContentType(ext string) {
 | ||
| 	(*context.BeegoOutput)(output).ContentType(ext)
 | ||
| }
 | ||
| 
 | ||
| // SetStatus sets response status code.
 | ||
| // It writes response header directly.
 | ||
| func (output *BeegoOutput) SetStatus(status int) {
 | ||
| 	(*context.BeegoOutput)(output).SetStatus(status)
 | ||
| }
 | ||
| 
 | ||
| // IsCachable returns boolean of this request is cached.
 | ||
| // HTTP 304 means cached.
 | ||
| func (output *BeegoOutput) IsCachable() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsCachable()
 | ||
| }
 | ||
| 
 | ||
| // IsEmpty returns boolean of this request is empty.
 | ||
| // HTTP 201,204 and 304 means empty.
 | ||
| func (output *BeegoOutput) IsEmpty() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsEmpty()
 | ||
| }
 | ||
| 
 | ||
| // IsOk returns boolean of this request runs well.
 | ||
| // HTTP 200 means ok.
 | ||
| func (output *BeegoOutput) IsOk() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsOk()
 | ||
| }
 | ||
| 
 | ||
| // IsSuccessful returns boolean of this request runs successfully.
 | ||
| // HTTP 2xx means ok.
 | ||
| func (output *BeegoOutput) IsSuccessful() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsSuccessful()
 | ||
| }
 | ||
| 
 | ||
| // IsRedirect returns boolean of this request is redirection header.
 | ||
| // HTTP 301,302,307 means redirection.
 | ||
| func (output *BeegoOutput) IsRedirect() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsRedirect()
 | ||
| }
 | ||
| 
 | ||
| // IsForbidden returns boolean of this request is forbidden.
 | ||
| // HTTP 403 means forbidden.
 | ||
| func (output *BeegoOutput) IsForbidden() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsForbidden()
 | ||
| }
 | ||
| 
 | ||
| // IsNotFound returns boolean of this request is not found.
 | ||
| // HTTP 404 means not found.
 | ||
| func (output *BeegoOutput) IsNotFound() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsNotFound()
 | ||
| }
 | ||
| 
 | ||
| // IsClientError returns boolean of this request client sends error data.
 | ||
| // HTTP 4xx means client error.
 | ||
| func (output *BeegoOutput) IsClientError() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsClientError()
 | ||
| }
 | ||
| 
 | ||
| // IsServerError returns boolean of this server handler errors.
 | ||
| // HTTP 5xx means server internal error.
 | ||
| func (output *BeegoOutput) IsServerError() bool {
 | ||
| 	return (*context.BeegoOutput)(output).IsServerError()
 | ||
| }
 | ||
| 
 | ||
| // Session sets session item value with given key.
 | ||
| func (output *BeegoOutput) Session(name interface{}, value interface{}) {
 | ||
| 	(*context.BeegoOutput)(output).Session(name, value)
 | ||
| }
 |