mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
* Add ability to properly configure logrus (e.x. specify output file) * Make the code slightly more ideomatic (sort imports, etc) * Replace some of the shell calls with equivalent native code * Fix update process * Improve error handling (handle 2 previously unhandled errors) * Add locking for HID operations and make a HID-operations struct a singleton
30 lines
973 B
Go
30 lines
973 B
Go
package router
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"NanoKVM-Server/middleware"
|
|
"NanoKVM-Server/service/vm"
|
|
)
|
|
|
|
func vmRouter(r *gin.Engine) {
|
|
service := vm.NewService()
|
|
api := r.Group("/api").Use(middleware.CheckToken())
|
|
|
|
api.GET("/vm/info", service.GetInfo) // get device information
|
|
|
|
api.POST("/vm/gpio", service.SetGpio) // update gpio
|
|
api.GET("/vm/gpio", service.GetGpio) // get gpio
|
|
api.POST("/vm/screen", service.SetScreen) // update screen
|
|
|
|
api.GET("/vm/terminal", service.Terminal) // web terminal
|
|
|
|
api.GET("/vm/script", service.GetScripts) // get script
|
|
api.POST("/vm/script/upload", service.UploadScript) // upload script
|
|
api.POST("/vm/script/run", service.RunScript) // run script
|
|
api.DELETE("/vm/script", service.DeleteScript) // delete script
|
|
|
|
api.GET("/vm/device/virtual", service.GetVirtualDevice) // get virtual device
|
|
api.POST("/vm/device/virtual", service.UpdateVirtualDevice) // update virtual device
|
|
}
|