Documentation ¶
Index ¶
- Constants
- Variables
- func AuthDirector(proxy *TorimaProxy, req *http.Request, c *gin.Context) (bool, error)
- func ConfigWeb(proxy *TorimaProxy, r *gin.RouterGroup)
- func DefaultRouteDirector(proxy *TorimaProxy, req *http.Request, c *gin.Context) (bool, error)
- func InjectHTMLModifyResponse(html string, proxy *TorimaProxy, res *http.Response, c *gin.Context) (bool, error)
- func InjectServiceWorkerModifyResponse(proxy *TorimaProxy, res *http.Response, c *gin.Context) (bool, error)
- func LogReq(req *http.Request)
- func LoginWebs(proxy *TorimaProxy, r *gin.RouterGroup)
- func MainModifyResponse(proxy *TorimaProxy, res *http.Response)
- func RouteDirector(host string, proxy *TorimaProxy, req *http.Request, c *gin.Context) (bool, error)
- func SanitizeHeaderDirector(proxy *TorimaProxy, req *http.Request, c *gin.Context) (bool, error)
- func StaticWeb(proxy *TorimaProxy, r *gin.RouterGroup)
- func ThirdPartyDirector(proxy *TorimaProxy, req *http.Request, c *gin.Context) (bool, error)
- type Database
- type FlowLog
- type FlowLogger
- type TorimaConfig
- type TorimaDirector
- type TorimaModifyResponse
- type TorimaPackageArgument
- type TorimaProxy
- type TorimaProxyWebPage
Constants ¶
View Source
const CONTINUE = true
View Source
const FINISHED = false
Variables ¶
View Source
var AUTH_PATH = gin_ninsho.NinshoGinPath{
Unauthorized: "/auth/login",
Callback: "/auth/callback",
AfterAuth: "/_torima/back",
}
View Source
var AfterLogDirector = MakeLogDirector("after")
View Source
var BeforeLogDirector = MakeLogDirector("before")
View Source
var CLIENT_ID = readEnvOrPanic("TORIMA_CLIENT_ID")
View Source
var CLIENT_SECRET = readEnvOrPanic("TORIMA_CLIENT_SECRET")
View Source
var CONFIG_FILE = "./config.yaml"
View Source
var DB_CONFIG = readEnv("TORIMA_DB_CONFIG", "file:./data/db.sqlite3?_fk=1")
View Source
var DB_TYPE = readEnv("TORIMA_DB_TYPE", "sqlite3")
configuration of DB
View Source
var DEFAULT_DIRECTORS = []TorimaDirector{ BeforeLogDirector, SanitizeHeaderDirector, AuthDirector, DefaultRouteDirector, ThirdPartyDirector, AfterLogDirector, }
other
View Source
var DEFAULT_MODIFY_RESPONSES = []TorimaModifyResponse{ InjectServiceWorkerModifyResponse, }
View Source
var DEFAULT_PROXYWEB_PAGES = []TorimaProxyWebPage{ ConfigWeb, StaticWeb, LoginWebs, }
View Source
var SECRET = readEnv("TORIMA_SECRET", randomString(32))
View Source
var STATIC_FOLDER = "./static"
Functions ¶
func AuthDirector ¶
func ConfigWeb ¶
func ConfigWeb(proxy *TorimaProxy, r *gin.RouterGroup)
func DefaultRouteDirector ¶
func LoginWebs ¶
func LoginWebs(proxy *TorimaProxy, r *gin.RouterGroup)
func MainModifyResponse ¶
func MainModifyResponse(proxy *TorimaProxy, res *http.Response)
func RouteDirector ¶
func SanitizeHeaderDirector ¶
func StaticWeb ¶
func StaticWeb(proxy *TorimaProxy, r *gin.RouterGroup)
func ThirdPartyDirector ¶
Types ¶
type Database ¶
func (*Database) CreateRequestLog ¶
type FlowLogger ¶
type FlowLogger struct {
// contains filtered or unexported fields
}
func NewFlowLogger ¶
func NewFlowLogger() FlowLogger
func (*FlowLogger) Add ¶
func (logger *FlowLogger) Add(f any, result bool)
func (*FlowLogger) Show ¶
func (flowLogs *FlowLogger) Show()
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"` WhiteListPath []string `yaml:"white_list_path" default:"[]"` ProtectionScope []string `yaml:"protection_scope" default:"[]"` WebRoot string `yaml:"web_root" default:"/torima"` }
type TorimaDirector ¶
func MakeLogDirector ¶
func MakeLogDirector(flag string) TorimaDirector
type TorimaModifyResponse ¶
type TorimaProxy ¶
type TorimaProxy struct { Directors []TorimaDirector ModifyResponses []TorimaModifyResponse ProxyWebPages []TorimaProxyWebPage Engine *gin.Engine Database *Database ErrorHandler *gin.HandlerFunc Config *TorimaConfig RequestCount int }
func NewOchancoProxy ¶
func NewOchancoProxy( r *gin.Engine, directors []TorimaDirector, modifyResponses []TorimaModifyResponse, proxyWebPages []TorimaProxyWebPage, config *TorimaConfig, database *Database, ) TorimaProxy
func ProxyServer ¶
func ProxyServer() (*TorimaProxy, error)
func (*TorimaProxy) Director ¶
func (proxy *TorimaProxy) Director(req *http.Request, c *gin.Context)
*
- Directors is a list of functions that modify the
- request before it is sent to the target server. *
func (*TorimaProxy) ModifyResponse ¶
*
- 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)
Click to show internal directories.
Click to hide internal directories.