rhttp

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteRules

func DeleteRules(c *gin.Context)

DeleteRules deletes http rule from user submit

func ListRules

func ListRules(c *gin.Context)

ListRules lists all http rules those satisfy the filter

func Records added in v0.2.1

func Records(c *gin.Context)

func UpsertRules

func UpsertRules(c *gin.Context)

UpsertRules create or update http rule from user submit

Types

type Config

type Config struct {
	IpHeader string `yaml:"ip_header"`
}

type Record

type Record struct {
	Method string `gorm:"index" form:"method" json:"method"`
	URI    string `form:"uri" json:"uri"`
	record.BaseRecord
	RawRequest string `json:"raw_request" notice:"-"`
	Rule       Rule   `gorm:"foreignKey:RuleName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" form:"-" json:"-" notice:"-"`
}

func NewRecord

func NewRecord(rule *Rule, flag, method, url, ip, area, raw string) (r *Record, err error)

func (Record) Notice

func (r Record) Notice()

func (Record) TableName

func (Record) TableName() string

type Rule

type Rule struct {
	rule.BaseRule      `yaml:",inline"`
	ResponseStatusCode string            `gorm:"index;default:200;not null" form:"response_status_code" json:"response_status_code" yaml:"response_status_code"`
	ResponseHeaders    database.MapField `form:"response_headers" json:"response_headers" yaml:"response_headers"`
	ResponseBody       string            `gorm:"type:longtext" form:"response_body" json:"response_body" yaml:"response_body"`
}

Rule Http rule struct

func NewRule

func NewRule(name, flagFormat, responseBody string, pushToClient, notice bool, responseStatus string, responseHeaders database.MapField) *Rule

NewRule new http rule struct

func (*Rule) CreateOrUpdate

func (r *Rule) CreateOrUpdate() (err error)

CreateOrUpdate creates or updates the http rule in database and ruleSet

func (*Rule) Delete

func (r *Rule) Delete() (err error)

Delete deletes the http rule in database and ruleSet

func (Rule) TableName

func (Rule) TableName() string

type Server

type Server struct {
	Addr     string
	Token    string
	IpHeader string
	Router   *gin.Engine
	ApiGroup *gin.RouterGroup
	// contains filtered or unexported fields
}

func GetServer

func GetServer() *Server

func (*Server) Receive

func (s *Server) Receive(c *gin.Context)

func (*Server) Restart

func (s *Server) Restart()

func (*Server) Run

func (s *Server) Run()

func (*Server) SetAddr

func (s *Server) SetAddr(addr string) *Server

func (*Server) SetIpHeader

func (s *Server) SetIpHeader(header string) *Server

func (*Server) SetToken

func (s *Server) SetToken(token string) *Server

func (*Server) UpdateRules

func (s *Server) UpdateRules() error

Jump to

Keyboard shortcuts

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