mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
Add Static Route Get API Method
This commit is contained in:
parent
d3ad3ff051
commit
139e385852
1 changed files with 18 additions and 0 deletions
|
@ -7,6 +7,24 @@ import (
|
|||
"nfsense.net/nfsense/internal/definitions/network"
|
||||
)
|
||||
|
||||
type GetStaticRouteParameters struct {
|
||||
ID uint
|
||||
}
|
||||
|
||||
type GetStaticRouteResult struct {
|
||||
network.StaticRoute
|
||||
}
|
||||
|
||||
func (f *Network) GetStaticRoute(ctx context.Context, params GetStaticRouteParameters) (GetStaticRouteResult, error) {
|
||||
if int(params.ID) >= len(f.ConfigManager.GetPendingConfig().Network.StaticRoutes) {
|
||||
return GetStaticRouteResult{}, fmt.Errorf("StaticRoute does not Exist")
|
||||
}
|
||||
|
||||
return GetStaticRouteResult{
|
||||
StaticRoute: f.ConfigManager.GetPendingConfig().Network.StaticRoutes[params.ID],
|
||||
}, nil
|
||||
}
|
||||
|
||||
type GetStaticRoutesResult struct {
|
||||
StaticRoutes []network.StaticRoute
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue