mirror of
https://github.com/safing/portmaster
synced 2025-09-02 10:39:22 +00:00
Improve APIs
This commit is contained in:
parent
660c1bf3c5
commit
50ea3a5d43
3 changed files with 18 additions and 12 deletions
|
@ -28,6 +28,8 @@ func registerAPIEndpoints() error {
|
||||||
Path: "core/shutdown",
|
Path: "core/shutdown",
|
||||||
Write: api.PermitSelf,
|
Write: api.PermitSelf,
|
||||||
ActionFunc: shutdown,
|
ActionFunc: shutdown,
|
||||||
|
Name: "Shut Down Portmaster",
|
||||||
|
Description: "Shut down the Portmaster Core Service and all UI components.",
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -36,6 +38,8 @@ func registerAPIEndpoints() error {
|
||||||
Path: "core/restart",
|
Path: "core/restart",
|
||||||
Write: api.PermitAdmin,
|
Write: api.PermitAdmin,
|
||||||
ActionFunc: restart,
|
ActionFunc: restart,
|
||||||
|
Name: "Restart Portmaster",
|
||||||
|
Description: "Restart the Portmaster Core Service.",
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,16 @@ func registerAPI() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := api.RegisterEndpoint(api.Endpoint{
|
if err := api.RegisterEndpoint(api.Endpoint{
|
||||||
Path: `dns/cache`,
|
Path: `dns/cache/{query:[a-z0-9\.-]{0,512}\.[A-Z]{1,32}}`,
|
||||||
Read: api.PermitUser,
|
Read: api.PermitUser,
|
||||||
RecordFunc: func(r *api.Request) (record.Record, error) {
|
RecordFunc: func(r *api.Request) (record.Record, error) {
|
||||||
return recordDatabase.Get(nameRecordsKeyPrefix + r.URL.Query().Get("q"))
|
return recordDatabase.Get(nameRecordsKeyPrefix + r.URLVars["query"])
|
||||||
},
|
},
|
||||||
Name: "Get DNS Record from Cache",
|
Name: "Get DNS Record from Cache",
|
||||||
Description: "Returns cached dns records from the internal cache.",
|
Description: "Returns cached dns records from the internal cache.",
|
||||||
Parameters: []api.Parameter{{
|
Parameters: []api.Parameter{{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Field: "q",
|
Field: "query (in path)",
|
||||||
Value: "fqdn and query type",
|
Value: "fqdn and query type",
|
||||||
Description: "Specify the query like this: `example.com.A`.",
|
Description: "Specify the query like this: `example.com.A`.",
|
||||||
}},
|
}},
|
||||||
|
|
|
@ -11,6 +11,8 @@ func registerAPIEndpoints() error {
|
||||||
Path: "ui/reload",
|
Path: "ui/reload",
|
||||||
Write: api.PermitUser,
|
Write: api.PermitUser,
|
||||||
ActionFunc: reloadUI,
|
ActionFunc: reloadUI,
|
||||||
|
Name: "Reload UI Assets",
|
||||||
|
Description: "Removes all assets from the cache and reloads the current (possibly updated) version from disk when requested.",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue