package main import ( "net/http" "gosvc/httpserver" ) func (s *Service) RegisterRouteRules() { s.HTTPServer.RegisterRouteRules( []*httpserver.RouteRule{ { Path: "/ping", Method: http.MethodGet, Handler: s.HandlePing, }, { Path: "/robotfs", SubRules: []*httpserver.RouteRule{ { Path: "/mkdir", Method: http.MethodPost, Handler: s.HandleMkdir, Bind: &MkdirParams{}, }, { Path: "/dir/list", Method: http.MethodGet, Handler: s.HandleListDirectory, QueryRules: []*httpserver.QueryRule{ { Key: "path", Type: httpserver.QueryTypeString, Required: true, }, { Key: "startFileName", Type: httpserver.QueryTypeString, }, { Key: "inclusive", Type: httpserver.QueryTypeBool, Required: true, }, { Key: "limit", Type: httpserver.QueryTypeInt, Required: true, Min: 1, Max: 4096, }, }, }, { Path: "/dir/delete", Method: http.MethodPost, Handler: s.HandleDeleteDirectory, Bind: &DeleteParams{}, }, { Path: "/dir/rename", Method: http.MethodPost, Handler: s.HandleRenameDirectory, Bind: &RenameParams{}, }, { Path: "/dir/copy", Method: http.MethodPost, Handler: s.HandleCopyDirectory, Bind: &CopyParams{}, }, { Path: "/file/upload", Method: http.MethodPost, Handler: s.HandleUploadFile, QueryRules: []*httpserver.QueryRule{ { Key: "path", Type: httpserver.QueryTypeString, Required: true, }, }, }, { Path: "/file/info", Method: http.MethodGet, Handler: s.HandleInfoFile, QueryRules: []*httpserver.QueryRule{ { Key: "path", Type: httpserver.QueryTypeString, Required: true, }, }, }, { Path: "/file/download", Method: http.MethodGet, Handler: s.HandleDownloadFile, QueryRules: []*httpserver.QueryRule{ { Key: "preview", Type: httpserver.QueryTypeBool, Required: true, }, { Key: "path", Type: httpserver.QueryTypeString, Required: true, }, }, }, { Path: "/file/delete", Method: http.MethodPost, Handler: s.HandleDeleteFile, Bind: &DeleteParams{}, }, { Path: "/file/rename", Method: http.MethodPost, Handler: s.HandleRenameFile, Bind: &RenameParams{}, }, { Path: "/file/copy", Method: http.MethodPost, Handler: s.HandleCopyFile, Bind: &CopyParams{}, }, }, }, }, ) }