types.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package nginx_log
  2. import "github.com/0xJacky/Nginx-UI/internal/translation"
  3. const (
  4. // PageSize defines the size of log chunks returned by the API
  5. PageSize = 128 * 1024
  6. )
  7. // controlStruct represents the request parameters for getting log content
  8. type controlStruct struct {
  9. Type string `json:"type"` // Type of log: "access" or "error"
  10. Path string `json:"path"` // Path to the log file
  11. }
  12. // nginxLogPageResp represents the response format for log content
  13. type nginxLogPageResp struct {
  14. Content string `json:"content"` // Log content
  15. Page int64 `json:"page"` // Current page number
  16. Error *translation.Container `json:"error,omitempty"` // Error message if any
  17. }
  18. // FileInfo represents basic file information
  19. type FileInfo struct {
  20. Exists bool `json:"exists"`
  21. Readable bool `json:"readable"`
  22. Size int64 `json:"size,omitempty"`
  23. LastModified int64 `json:"last_modified,omitempty"`
  24. }
  25. // TimeRange represents a time range for log data
  26. type TimeRange struct {
  27. Start int64 `json:"start"`
  28. End int64 `json:"end"`
  29. }
  30. // PreflightResponse represents the response from preflight checks
  31. type PreflightResponse struct {
  32. Available bool `json:"available"`
  33. IndexStatus string `json:"index_status"`
  34. Message string `json:"message,omitempty"`
  35. TimeRange *TimeRange `json:"time_range,omitempty"`
  36. FileInfo *FileInfo `json:"file_info,omitempty"`
  37. }
  38. // AnalyticsResponse represents the response for analytics endpoints
  39. type AnalyticsResponse struct {
  40. Entries []map[string]interface{} `json:"entries"`
  41. Count int `json:"count"`
  42. }
  43. // GeoDataResponse represents the response for geographic data
  44. type GeoDataResponse struct {
  45. Data []GeoDataItem `json:"data"`
  46. }
  47. // GeoRegionResponse represents the response for geographic region data
  48. type GeoRegionResponse struct {
  49. Data []GeoRegionItem `json:"data"`
  50. }
  51. // GeoStatsResponse represents the response for geographic statistics
  52. type GeoStatsResponse struct {
  53. Stats []interface{} `json:"stats"`
  54. }
  55. // ErrorResponse represents a standard error response
  56. type ErrorResponse struct {
  57. Error string `json:"error"`
  58. }
  59. // IndexRebuildResponse represents the response for index rebuild operations
  60. type IndexRebuildResponse struct {
  61. Message string `json:"message"`
  62. Status string `json:"status"`
  63. }
  64. // LogListSummary represents summary statistics for log list
  65. type LogListSummary struct {
  66. TotalFiles int `json:"total_files"`
  67. IndexedFiles int `json:"indexed_files"`
  68. IndexingFiles int `json:"indexing_files"`
  69. DocumentCount int `json:"document_count"`
  70. }
  71. // LogListResponse represents the response for log list endpoint
  72. type LogListResponse struct {
  73. Data interface{} `json:"data"`
  74. Summary LogListSummary `json:"summary"`
  75. }