endpoints

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHealth

func CheckHealth(ctx *gin.Context)

CheckHealth is a health check endpoint. It returns a 200 OK status code.

func CheckStatus added in v0.0.12

func CheckStatus(ctx *gin.Context)

CheckStatus is a workaround to return a valid response for status.kagi.com. Status.kagi.com returns for some requests a valid response but the status is always "404". This is a workaround to return a valid response.

func Proxy

func Proxy() gin.HandlerFunc

Proxy is an endpoint handler that proxies requests to the kagi.com and *.kagi.com servers. It also injects a session token into the request if it is not already present. It applies custom reverse proxy with mutation observer, CSP handling, and response compression.

func SignInForm

func SignInForm(ctx *gin.Context)

SignInForm is a handler that authenticates the user. If the user is not authenticated, it redirects to the login page. If the user is authenticated, it redirects to the root page or the location he attempted to access before page. It supports two actions: login and signup. Login action authenticates the user with username, password, and OTP. Signup action generates a QR code for the user to set up OTP.

func SignInWeb

func SignInWeb(ctx *gin.Context)

SignInWeb is a handler that displays the login page. It displays the login page with renders the flash messages originating from the session.

func SignOut

func SignOut(ctx *gin.Context)

SignOut is a handler that logs out the user.

Types

type ProxyState

type ProxyState struct {
	// RetryConfig is the configuration for retrying requests.
	RetryConfig web.RetryConfig
	// SessionCreatedAt is the time the session was created.
	SessionCreatedAt time.Time
	// SessionId is the session ID.
	SessionId string
}

ProxyState preserves the state of the proxy handler.

func (ProxyState) Director

func (p ProxyState) Director(req *http.Request)

Director is a function that modifies the request before it is sent. It injects a session token into the request if it is not already present. It also modifies the request to use the target host specified in the targetHostConfig.

func (ProxyState) ErrorHandler

func (ProxyState) ErrorHandler(w http.ResponseWriter, r *http.Request, err error)

ErrorHandler is a function that handles errors that occur during the proxying process.

func (ProxyState) ModifyResponse

func (p ProxyState) ModifyResponse(resp *http.Response) error

ModifyResponse is a function that modifies the response before it is sent. It injects a script that proxies requests to the target hosts specified in the targetHostConfig.

Jump to

Keyboard shortcuts

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