pocket

package
v0.6.21 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

this version of pocket doesn't support connect proxy

Index

Constants

This section is empty.

Variables

View Source
var HOST = utils.EnvHost("")
View Source
var RelayHook = &hook.Handler[*core.ServeEvent]{
	Func: func(se *core.ServeEvent) error {
		if HOST == "" {
			return se.Next()
		}

		log.Println("starting the relay server", "HOST", HOST)

		store := relay.NewSessionStore()

		if os.Getenv("LOGGIN") != "" {
			store.Use(utils.GinLoggerMiddleware)
		}

		mini := relay.NewWSServer(HOST, store)

		se.Router.BindFunc(func(re *core.RequestEvent) error {
			r := re.Event.Request
			isPocketbaseHost := mini.IsRootExternal(r)
			isAPI := strings.HasPrefix(r.URL.Path, "/api/")
			isUI := strings.HasPrefix(r.URL.Path, "/_/")
			isPocketbase := isPocketbaseHost && (isAPI || isUI)

			if os.Getenv("VERBOSE") != "" {
				log.Println(fmt.Sprintf("isPocketbase (%v) := isPocketbaseHost (%v) && (isAPI (%v) || isUI (%v))", isPocketbase, isPocketbaseHost, isAPI, isUI))
			}

			if !isPocketbase {
				mini.ServeHTTP(re.Event.Response, re.Event.Request)
				return nil
			}

			return re.Next()
		})

		return se.Next()
	},
	Priority: -99999,
}

Functions

func Run

func Run(args []string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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