split rest.go in several files

The file started to be a bit long, it's now splited in logical parts.