165 Commits

Author SHA1 Message Date
73b13fd60b fix(public): update link in index.md to correct URL 2025-01-01 01:36:23 +08:00
wood chen
52d2e1bdb7
Update readme.md 2024-12-31 15:34:28 +08:00
wood chen
1ca0ec6ad7
Update readme.md 2024-12-31 12:11:27 +08:00
226135aea2 refactor(public, workflows): update public file paths and remove top referers display
- Changed the file paths in the Docker workflow to reflect the new directory structure for public assets.
- Removed the top referers display section from index.html to streamline the user interface and improve performance.
- Ensured proper cleanup and permissions for the new public data directory in the Docker workflow.
2024-12-02 05:58:56 +08:00
32fb07a2ee feat(public): add top referers display to metrics summary
- Introduced a new section in the index.html to display the top referers with their respective counts.
- Implemented dynamic rendering of referers based on available data, enhancing user insights into traffic sources.
- Ensured the referers are sorted by count for better visibility and understanding of user access patterns.
2024-12-02 05:53:02 +08:00
b252b8313e refactor(handlers): simplify referer handling in API request logging
- Removed custom referer parsing logic and replaced it with direct usage of r.Referer() for cleaner code.
- Updated logging to consistently use the referer from the request object across all relevant handlers.
- Enhanced readability and maintainability by eliminating redundant code related to referer extraction.
2024-12-02 05:45:39 +08:00
d3933374af refactor(middleware, monitoring, public): streamline metrics handling and remove top referers display
- Simplified MetricsMiddleware by removing unnecessary comments and focusing on essential request logging.
- Updated RequestLog structure to exclude the Referer field from JSON serialization, enhancing data privacy.
- Removed top referers tracking and associated HTML/CSS elements to declutter the user interface and improve performance.
- Cleaned up CSS styles related to referers for a more streamlined design.
2024-12-02 05:35:24 +08:00
6a0df0bdc7 feat(public): enhance system metrics display and user interface
- Added a main title to the index.html for better context.
- Introduced a new stats container to organize summary and detail statistics.
- Implemented a refresh animation for loading stats, improving user experience.
- Updated the updateStats function to streamline data handling and display.
- Enhanced the metrics section with improved formatting and error handling.
- Refined CSS styles for better visual presentation and responsiveness.
- Ensured a cleaner layout for system metrics and top referers, contributing to a more intuitive interface.
2024-12-01 02:47:23 +08:00
454fe7380f fix(public): update metrics API endpoint for consistency 2024-12-01 02:13:32 +08:00
260bddb56b refactor(public): improve metrics loading and display logic
- Updated the metrics API endpoint from '/metrics' to '/api/metrics' for better organization.
- Added data validation to ensure the metrics data received is an object, enhancing error handling.
- Refactored the updateMetricsDisplay function to dynamically create metric items, improving the display of metrics.
- Implemented HTML escaping for metric keys and values to prevent XSS vulnerabilities.
- Cleared existing content in the metrics container before updating, ensuring a clean display.
2024-12-01 01:49:50 +08:00
50e6abaa2f refactor(monitoring): enhance TopReferers handling and JSON serialization
- Improved LogRequest function to correctly increment counts for referers, ensuring accurate tracking of direct and indirect accesses.
- Added MarshalJSON method to SystemMetrics for proper serialization of TopReferers, facilitating better JSON representation of metrics.
- Updated comments for clarity and maintainability, enhancing code readability.
2024-12-01 01:46:57 +08:00
813d87531f refactor(monitoring, public): enhance system metrics and update display logic
- Streamlined SystemMetrics by removing unnecessary fields and focusing on essential metrics such as AverageLatency and MemoryStats.
- Updated LogRequest to improve handling of referers and average latency calculations, ensuring accurate metrics collection.
- Enhanced the HTML display to include a dedicated section for system metrics, ensuring graceful handling of undefined values.
- Improved the presentation of top referers with a time-based reset mechanism, contributing to a cleaner and more efficient user interface.
2024-12-01 01:43:54 +08:00
8d0d502910 refactor(monitoring, public): remove recent requests tracking and update metrics display
- Removed the RecentRequests field from SystemMetrics and its associated logic in LogRequest to streamline metrics collection.
- Updated the HTML to eliminate the recent requests section, focusing on the top referers display for improved performance and clarity.
- Enhanced the overall metrics presentation by ensuring only relevant data is displayed, contributing to a cleaner user interface.
2024-12-01 01:25:24 +08:00
f92b8385d8 fix(handlers, public): update timestamp logging to use Unix milliseconds
- Changed timestamp logging in the HandleAPIRequest function to use Unix milliseconds for improved precision.
- Updated the recent requests display in the HTML to correctly parse and format timestamps using the new millisecond format, enhancing readability and consistency in metrics presentation.
2024-12-01 00:55:20 +08:00
0a41bebf39 fix(monitoring): add global locks to LogRequest for thread safety
- Introduced global locks to protect concurrent writes to metrics maps in the LogRequest function.
- Ensured thread safety for updating status codes, path latencies, and recent requests, preventing data races.
- Improved overall reliability of metrics logging during high concurrency scenarios.
2024-12-01 00:50:09 +08:00
386e80914f refactor(monitoring, public): streamline latency formatting and metrics logging
- Removed the obsolete formatLatency function from metrics.go to simplify the codebase.
- Updated the HTML to utilize the new latency formatting method, ensuring consistent display of average latency metrics.
- Enhanced the LogRequest function to accurately calculate and update average latency based on request counts, improving metrics accuracy.
2024-12-01 00:46:16 +08:00
1248508302 refactor(handlers, monitoring): improve API request handling and metrics logging
- Refactored HandleAPIRequest to use a result channel for better error handling and response management.
- Updated metrics logging to directly use the full referer instead of just the main domain, enhancing data accuracy.
- Fixed recent requests display in HTML to correctly format timestamps for better readability.
2024-12-01 00:37:50 +08:00
2720f6ebf0 feat(monitoring, public): improve latency formatting and enhance metrics logging
- Updated latency formatting in Go and JavaScript to display three decimal places for improved precision.
- Enhanced LogRequest function to store only the main domain of the referer, improving data clarity.
- Added MarshalJSON method to SystemMetrics for better JSON representation of request counts.
2024-12-01 00:29:48 +08:00
d6fd055cd5 fix(handlers): add HTTP redirect for API requests
- Implemented an HTTP redirect to a random URL in the HandleAPIRequest function, enhancing user experience by guiding users to the appropriate resource after processing their request.
2024-12-01 00:20:23 +08:00
80d18f2b88 feat(config, handlers, middleware): enhance configuration and API request handling
- Added performance settings to the configuration, including max concurrent requests and caching options.
- Updated API request handling to use context for timeouts and improved logging with Unix timestamps.
- Introduced rate limiting middleware to manage request load effectively.
- Enhanced metrics logging to include atomic counters for request counts and improved data structure for performance metrics.
- Implemented caching for CSV content to optimize data retrieval and reduce load times.
2024-12-01 00:14:21 +08:00
83e0226e41 feat(monitoring, public): enhance metrics logging and display
- Added a new function to format latency metrics in both Go and JavaScript for improved readability.
- Updated the LogRequest function to parse and store only the domain of the referer, enhancing data clarity.
- Modified the recent requests and top referers display logic in the HTML to improve performance and maintainability.
- Ensured that the recent requests are displayed in a more user-friendly format, including formatted latency values.
2024-12-01 00:03:26 +08:00
fd9c616aa2 feat(main, handlers): initialize random number generator and enhance URL stats response format
- Added initialization of a random number generator in main.go to support future features.
- Refactored HandleURLStats in handlers.go to return URL statistics in a structured format, improving API response clarity and usability.
2024-11-30 23:56:21 +08:00
1b2fd3ea85 feat(handlers, monitoring, public): enhance API request handling and improve metrics logging
- Implemented detailed logging for API requests, including real IP, referer, and latency metrics.
- Added dynamic routing for handling requests to /pic/ and /video/ endpoints.
- Enhanced error handling for CSV content fetching and improved response messages.
- Updated the HTML and JavaScript to load and display statistics more efficiently, including filtering based on endpoint configuration.
- Introduced new metrics collection logic to only log relevant API requests, optimizing performance and clarity.
2024-11-30 23:52:31 +08:00
44afb8cae9 fix(config, docker): update log file path and BASE_URL for consistency
- Changed log_file path in config.json to point to /root/data/logs/server.log.
- Updated BASE_URL in docker-compose.yml to use https://example.net/random-api for improved clarity and consistency.
2024-11-30 23:38:43 +08:00
1fc1069ec1 refactor(docker, config): streamline directory structure and enhance configuration management
- Removed unnecessary volume mounts for public and logs in docker-compose.yml.
- Updated Dockerfile to create necessary directories under /root/data.
- Modified start.sh to copy files to the new public directory location.
- Enhanced config.go to create default configuration and directory structure if not present.
- Adjusted router.go to serve static files from the new public directory path.
2024-11-30 23:34:45 +08:00
88c86787a0 refactor(main): reorder configuration loading and directory creation in Initialize method
- Moved the configuration loading to occur before creating necessary directories.
- Improved code clarity by ensuring that configuration is loaded prior to any directory operations.
2024-11-30 23:30:17 +08:00
e70ca4cf52 feat(docker, config, api): update docker-compose for logging, enhance app structure, and add system metrics display
- Updated docker-compose.yml to mount logs directory.
- Changed BASE_URL environment variable to point to the new API endpoint.
- Refactored main.go to implement a structured App type, improving initialization and graceful shutdown.
- Enhanced config management with JSON loading and environment variable support.
- Added monitoring capabilities in api_handler for logging request metrics.
- Introduced new metrics display in index.html with corresponding CSS styles for better visualization.
2024-11-30 23:23:58 +08:00
f31ff5caa7 feat(generate_csv): fetch album mapping from remote instead of local file 2024-11-17 07:18:15 +08:00
eb7ddee0af chore(lankong_tools): update album_mapping.json for truegirl.csv 2024-11-17 00:27:16 +08:00
365c3a8936 2728 2024-11-16 07:00:20 +08:00
a4d6890a78 refactor(public, services): improve HTML structure and optimize CSV service logging 2024-11-16 05:45:24 +08:00
61e84d87b8 chore(workflow,ci): update docker build process and add multi-arch support
Update the GitHub Actions workflow to include Go setup, multi-arch builds, and push multi-arch Docker images. Also, refactor the CSV service to improve logging and caching mechanism.
2024-11-16 05:34:37 +08:00
981759be39 feat(api, services, handlers): add URL statistics endpoint and service initialization 2024-11-16 05:21:05 +08:00
88986bb637 refactor: update analytics script in index.html 2024-11-15 18:29:48 +08:00
098abf86bf feat(public): add clarity analytics script 2024-11-15 15:14:14 +08:00
152c45605d chore(lankong_tools): update album_mapping.json for truegirl.csv 2024-11-03 09:49:46 +08:00
973fe5c8de style(api_handler): adjust log format for better readability 2024-11-03 08:25:31 +08:00
402c6cf82d refactor(api_handler): remove unused log statement 2024-11-03 08:15:05 +08:00
1b2106697f refactor(api_handler): improve logging format for API request handling 2024-11-03 08:14:50 +08:00
wood chen
aac15c23c9
Update readme.md 2024-11-02 13:14:29 +08:00
275190681c docs(public): Update statistics start date to 2024-11-1 2024-11-02 13:12:39 +08:00
f8f14165d2 docs: add description meta tag to index.html 2024-11-02 13:04:53 +08:00
e03550423d fix: Update start date in stats update function 2024-11-02 13:03:02 +08:00
63106f9008 chore(Dockerfile): add tzdata for proper timezone handling 2024-10-31 01:17:18 +08:00
9c4d57c9b8 Merge branch 'main' of https://github.com/woodchen-ink/random-api-go 2024-10-31 01:08:33 +08:00
887e8a7ca8 refactor(api_handler): improve source info extraction and logging 2024-10-31 01:08:30 +08:00
wood chen
018e22f681
Create LICENSE 2024-10-31 00:40:00 +08:00
f68fa981ce chore(workflow): add push event trigger for generate-csv.yml 2024-10-31 00:33:08 +08:00
967daa51da fix: update album mapping file path 2024-10-31 00:22:57 +08:00
1f35985ef4 refactor(lankong_tools): update album mapping structure and processing logic 2024-10-31 00:21:31 +08:00