rsweb

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	C_Data_Pass               = "pass"
	C_Data_Pending            = "pending"
	C_Data_Success            = "successed"
	C_Error_Denied            = "permission denied"
	C_Error_InvalidParams     = "invalid request params"
	C_Error_SystenmExeception = "system processing exception"
)

Variables

View Source
var EnableLog = true

Functions

func HttpGetByFunc

func HttpGetByFunc(url string, fHandle func(buf []byte)) error

http.Request

func HttpPostByFunc

func HttpPostByFunc(url string, form url.Values, fHandle func(buf []byte)) error

func Init

func Init(webPath string, fs *embed.FS, routerFuncList ...func(*httprouter.Router)) *httprouter.Router

func NewAPILog

func NewAPILog(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func NewCors

func NewCors(allowCredentials bool, allowOrigins ...string) negroni.Handler

func NewGzip

func NewGzip(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func NewRateLimite

func NewRateLimite() negroni.Handler

func ResponseDirect

func ResponseDirect(w http.ResponseWriter, r *http.Request, data []byte, strType string)

http.Response

func ResponseError

func ResponseError(w http.ResponseWriter, r *http.Request, errorInfo string)

func ResponseOk

func ResponseOk(w http.ResponseWriter, r *http.Request, data interface{})

func ResponseOkIndent

func ResponseOkIndent(w http.ResponseWriter, r *http.Request, data interface{}, prefix, indent string)

func ResponseRedirect

func ResponseRedirect(w http.ResponseWriter, r *http.Request, url string)

func ResponseToken

func ResponseToken(w http.ResponseWriter, r *http.Request, data interface{}, token string)

func Run

func Run(ctx context.Context, port string, handler func() http.Handler)
example:
rsweb.Run(ctx, "8080", func() http.Handler {
	n := negroni.New()
	n.Use(rsweb.NewCors(allowCredentials, allowOrigins...))
	n.UseFunc(rsweb.NewGzip)
	n.Use(rsweb.NewRateLimite())
	n.UseFunc(rsweb.NewAPILog)
	n.UseHandlerFunc(router.ServeHTTP)
	return n
})

func Run(ctx context.Context, port string, router *httprouter.Router, allowCredentials bool, allowOrigins ...string) {

func WebDecryptParams

func WebDecryptParams(r *http.Request, decryptFunc func(s string, v *url.Values)) url.Values

func WebError

func WebError(err error, webErr string) string

func WebParams

func WebParams(r *http.Request) url.Values

Types

type WebResponse

type WebResponse struct {
	Data     interface{}
	Redirect string
	Error    string
}

====================================== http =========================================

Jump to

Keyboard shortcuts

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