Skip to content

Commit

Permalink
fix(api): refactor, use basic auth and new endpoint
Browse files Browse the repository at this point in the history
Changes:
- use standard basic authentication headers for reporting APIs
- change API prefix from /reports to /monitoring
- consolidate all monitoring APIs inside one endpoint
  • Loading branch information
gsanchietti committed Sep 20, 2024
1 parent 10a56bc commit cb03868
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 265 deletions.
30 changes: 17 additions & 13 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,23 @@ func main() {
}
}

// report APIs
reports := router.Group("/reports")
reports.Use(middleware.ReportAuth())
{
reports.POST("/mwan-events", methods.UpdateMwanSeries)
reports.POST("/ts-attacks", methods.UpdateTsAttacks)
reports.POST("/ts-malware", methods.UpdateTsMalware)
reports.POST("/ovpnrw-connections", methods.UpdateOvpnConnections)
reports.POST("/dpi-stats", methods.UpdateDpiStats)
reports.POST("/unit-name", methods.SetUnitName)
reports.POST("/unit-openvpn", methods.SetUnitOpenVPNRW)
reports.POST("/unit-wan", methods.SetUnitWan)
}
// monitoring APIs
authorized := router.Group("/monitoring", middleware.BasicAuth())
authorized.POST("/:metric", methods.HandelMonitoring)
//authorized.POST("/unit-name", methods.SetUnitName)

//reports := router.Group("/reports")
// reports.Use(middleware.ReportAuth())
// {
// reports.POST("/mwan-events", methods.UpdateMwanSeries)
// reports.POST("/ts-attacks", methods.UpdateTsAttacks)
// reports.POST("/ts-malware", methods.UpdateTsMalware)
// reports.POST("/ovpnrw-connections", methods.UpdateOvpnConnections)
// reports.POST("/dpi-stats", methods.UpdateDpiStats)
// reports.POST("/unit-name", methods.SetUnitName)
// reports.POST("/unit-openvpn", methods.SetUnitOpenVPNRW)
// reports.POST("/unit-wan", methods.SetUnitWan)
// }

// handle missing endpoint
router.NoRoute(func(c *gin.Context) {
Expand Down
Loading

0 comments on commit cb03868

Please sign in to comment.