Documentation
¶
Index ¶
- Constants
- Variables
- func EnsureSessionPublic() error
- func FetchDocument(targetURL string) (*goquery.Document, error)
- func FetchDocumentWithRetry(url string, referrer string, maxRetries int) (*goquery.Document, error)
- func GetCSRFToken(url string) (string, error)
- func GetCookieJar() (http.CookieJar, error)
- func GetJadwal(url string) (models.Jadwal, error)
- func GetKegiatan(url string) ([]models.Kegiatan, error)
- func GetKelasbaru(baseURL string) ([]models.KelasBaru, error)
- func GetMahasiswaBaru(url string) ([]models.MahasiswaBaru, error)
- func GetTimeStampLUT() ([][]string, error)
- func GetUTS(url string) ([]models.UTS, error)
- func IsCloudflareChallenge(html string) bool
- func WriteErrorResponse(w http.ResponseWriter, status int, message string)
- func WriteErrorResponseWithCode(w http.ResponseWriter, status int, message string, code string)
- func WriteHTTPError(w http.ResponseWriter, err error)
- func WriteInternalServerError(w http.ResponseWriter)
- func WriteJSONResponse(w http.ResponseWriter, data interface{})
- func WriteNotFoundError(w http.ResponseWriter)
- func WriteValidationError(w http.ResponseWriter, message string)
- type Cache
- type CacheItem
- type CacheStats
- type CircuitBreaker
- type CircuitBreakerStats
- type CircuitState
- type FlareCookie
- type FlareSolverr
- type FlareSolverrRequest
- type FlareSolverrResponse
- type ProxyManager
- type Response
Constants ¶
const ( BaseURL = "https://baak.gunadarma.ac.id" BaseIP = "103.23.40.57" // IP address for direct access )
Variables ¶
var (
ErrCircuitOpen = errors.New("circuit breaker is open")
)
var (
Limiter = rate.NewLimiter(rate.Limit(5), 10)
)
Functions ¶
func EnsureSessionPublic ¶
func EnsureSessionPublic() error
EnsureSessionPublic is a public wrapper around ensureSession
func FetchDocumentWithRetry ¶
Fetch a document with proper referrer and headers
func GetCSRFToken ¶
GetCSRFToken fetches a page and extracts the CSRF token from a hidden input field.
func GetCookieJar ¶
GetCookieJar returns a cookie jar for HTTP requests
func GetMahasiswaBaru ¶
func GetMahasiswaBaru(url string) ([]models.MahasiswaBaru, error)
func GetTimeStampLUT ¶
func IsCloudflareChallenge ¶
IsCloudflareChallenge checks if the HTML response is a Cloudflare challenge
func WriteErrorResponse ¶
func WriteErrorResponse(w http.ResponseWriter, status int, message string)
func WriteErrorResponseWithCode ¶
func WriteErrorResponseWithCode(w http.ResponseWriter, status int, message string, code string)
func WriteHTTPError ¶
func WriteHTTPError(w http.ResponseWriter, err error)
func WriteInternalServerError ¶
func WriteInternalServerError(w http.ResponseWriter)
func WriteJSONResponse ¶
func WriteJSONResponse(w http.ResponseWriter, data interface{})
func WriteNotFoundError ¶
func WriteNotFoundError(w http.ResponseWriter)
func WriteValidationError ¶
func WriteValidationError(w http.ResponseWriter, message string)
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a simple in-memory cache with TTL
type CacheStats ¶
type CacheStats struct {
TotalItems int `json:"total_items"`
ValidItems int `json:"valid_items"`
ExpiredItems int `json:"expired_items"`
}
CacheStats holds cache statistics
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker implements the circuit breaker pattern
func GetCircuitBreaker ¶
func GetCircuitBreaker() *CircuitBreaker
GetCircuitBreaker returns the singleton circuit breaker
func (*CircuitBreaker) Allow ¶
func (cb *CircuitBreaker) Allow() error
Allow checks if a request is allowed through
func (*CircuitBreaker) RecordFailure ¶
func (cb *CircuitBreaker) RecordFailure()
RecordFailure records a failed request
func (*CircuitBreaker) RecordSuccess ¶
func (cb *CircuitBreaker) RecordSuccess()
RecordSuccess records a successful request
func (*CircuitBreaker) Reset ¶
func (cb *CircuitBreaker) Reset()
Reset resets the circuit breaker to closed state
func (*CircuitBreaker) State ¶
func (cb *CircuitBreaker) State() CircuitState
State returns the current circuit breaker state
func (*CircuitBreaker) Stats ¶
func (cb *CircuitBreaker) Stats() CircuitBreakerStats
Stats returns circuit breaker statistics
type CircuitBreakerStats ¶
type CircuitBreakerStats struct {
State string `json:"state"`
Failures int `json:"failures"`
Successes int `json:"successes"`
LastFailureTime time.Time `json:"last_failure_time,omitempty"`
}
CircuitBreakerStats holds circuit breaker statistics
type CircuitState ¶
type CircuitState int
CircuitState represents the state of the circuit breaker
const ( CircuitClosed CircuitState = iota CircuitOpen CircuitHalfOpen )
func (CircuitState) String ¶
func (s CircuitState) String() string
type FlareCookie ¶
type FlareCookie struct {
Name string `json:"name"`
Value string `json:"value"`
Domain string `json:"domain"`
Path string `json:"path"`
Expires int64 `json:"expires"`
HttpOnly bool `json:"httpOnly"`
Secure bool `json:"secure"`
}
FlareCookie represents a cookie from FlareSolverr
type FlareSolverr ¶
type FlareSolverr struct {
// contains filtered or unexported fields
}
FlareSolverr handles requests through FlareSolverr proxy
func GetFlareSolverr ¶
func GetFlareSolverr() *FlareSolverr
GetFlareSolverr returns the FlareSolverr instance if configured
func (*FlareSolverr) CheckHealth ¶
func (fs *FlareSolverr) CheckHealth() error
CheckHealth checks if FlareSolverr is reachable and working
func (*FlareSolverr) Fetch ¶
func (fs *FlareSolverr) Fetch(targetURL string) (string, error)
Fetch fetches a URL through FlareSolverr
func (*FlareSolverr) IsConfigured ¶
func (fs *FlareSolverr) IsConfigured() bool
IsConfigured returns true if FlareSolverr is configured
type FlareSolverrRequest ¶
type FlareSolverrRequest struct {
Cmd string `json:"cmd"`
URL string `json:"url"`
MaxTimeout int `json:"maxTimeout"`
}
FlareSolverrRequest represents a request to FlareSolverr
type FlareSolverrResponse ¶
type FlareSolverrResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Solution struct {
URL string `json:"url"`
Status int `json:"status"`
Headers map[string]string `json:"headers"`
Response string `json:"response"`
Cookies []FlareCookie `json:"cookies"`
UserAgent string `json:"userAgent"`
} `json:"solution"`
}
FlareSolverrResponse represents a response from FlareSolverr
type ProxyManager ¶
type ProxyManager struct {
// contains filtered or unexported fields
}
ProxyManager handles proxy rotation for HTTP requests
func GetProxyManager ¶
func GetProxyManager() *ProxyManager
GetProxyManager returns the singleton proxy manager
func (*ProxyManager) AddProxy ¶
func (pm *ProxyManager) AddProxy(proxy *url.URL)
AddProxy adds a proxy to the manager
func (*ProxyManager) GetClient ¶
func (pm *ProxyManager) GetClient() (*http.Client, error)
GetClient returns an http.Client with a proxy-enabled transport
func (*ProxyManager) GetTransport ¶
func (pm *ProxyManager) GetTransport() *http.Transport
GetTransport returns an http.Transport with the next proxy
func (*ProxyManager) HasProxies ¶
func (pm *ProxyManager) HasProxies() bool
HasProxies returns true if proxies are configured