core

package
v0.0.0-...-1c22a90 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CLIENT_ID = utils.ReadEnvOrPanic("TORIMA_CLIENT_ID")
View Source
var CLIENT_SECRET = utils.ReadEnvOrPanic("TORIMA_CLIENT_SECRET")
View Source
var CONFIG_FILE = "./config.yaml"
View Source
var DB_CONFIG = utils.ReadEnv("TORIMA_DB_CONFIG", "file:./data/db.sqlite3?_fk=1")
View Source
var DB_TYPE = utils.ReadEnv("TORIMA_DB_TYPE", "sqlite3")

configuration of DB

View Source
var SECRET = utils.ReadEnv("TORIMA_SECRET", utils.RandomString(32))
View Source
var STATIC_FOLDER = "./static"

Functions

This section is empty.

Types

type Database

type Database struct {
	Ctx    context.Context
	Client *ent.Client
}

func InitDB

func InitDB(path string) (*Database, error)

func (*Database) CreateRequestLog

func (db *Database) CreateRequestLog(header string, body []byte, flag string) *ent.RequestLogCreate

type TorimaConfig

type TorimaConfig struct {
	DefaultOrigin   string   `yaml:"default_origin" default:"127.0.0.1:5000"`
	Host            string   `yaml:"host" default:"http://127.0.0.1:8080"`
	Port            int      `yaml:"port" default:"8080" `
	Scheme          string   `yaml:"scheme" default:"http"`
	SkipAuthList    []string `yaml:"skip_auth_list" default:"[]"`
	ProtectionScope []string `yaml:"protection_scope" default:"[]"`
	WebRoot         string   `yaml:"web_root" default:"/torima"`
}

func ReadConfig

func ReadConfig() (*TorimaConfig, error)

type TorimaDirectorPackageContext

type TorimaDirectorPackageContext = TorimaPackageContext[*http.Request]

type TorimaModifyResponsePackageContext

type TorimaModifyResponsePackageContext = TorimaPackageContext[*http.Response]

type TorimaPackageContext

type TorimaPackageContext[T TorimaPackageTarget] struct {
	Proxy         *TorimaProxy
	Target        T
	GinContext    *gin.Context
	PackageStatus TorimaPackageStatus
}

type TorimaPackageStatus

type TorimaPackageStatus = int
const (
	AuthNeeded TorimaPackageStatus = iota
	Authed
	NoAuthNeeded
	ForceStop
	Keep
)

type TorimaPackageTarget

type TorimaPackageTarget interface{ *http.Request | *http.Response }

type TorimaProxy

type TorimaProxy struct {
	Directors       TorimaDirectors
	ModifyResponses TorimaModifyResponses
	ProxyWebPages   []TorimaProxyWebPage
	Engine          *gin.Engine
	Database        *Database
	ErrorHandler    *gin.HandlerFunc
	Config          *TorimaConfig
	RequestCount    int
}

func NewOchancoProxy

func NewOchancoProxy(
	r *gin.Engine,
	directors TorimaDirectors,
	modifyResponses TorimaModifyResponses,
	proxyWebPages []TorimaProxyWebPage,
	config *TorimaConfig,
	database *Database,
) TorimaProxy

func (*TorimaProxy) Director

func (proxy *TorimaProxy) Director(req *http.Request, ginContext *gin.Context)

*

  • Directors is a list of functions that modify the
  • request before it is sent to the target server. *

func (*TorimaProxy) ModifyResponse

func (proxy *TorimaProxy) ModifyResponse(res *http.Response, ginContext *gin.Context) error

*

  • ModifyResponses is a list of functions that modify the
  • response before it is sent to the client.

*

type TorimaProxyWebPage

type TorimaProxyWebPage = func(proxy *TorimaProxy, c *gin.RouterGroup)

Jump to

Keyboard shortcuts

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