crud
You can add routes using the standard http methods, such as GET, POST, PUT, PATCH, and DELETE. In the below example, all the different http verbs will be pointing to the ping controller's ping method.
import { PsychicRouter } from 'psychic'
import PingController from '../app/controllers/PingController'
export default (r: PsychicRouter) => {
r.get('/ping', PingController, 'ping')
r.post('/ping', PingController, 'ping')
r.put('/ping', PingController, 'ping')
r.patch('/ping', PingController, 'ping')
r.delete('/ping', PingController, 'ping')
}
GET /ping Ping#ping POST /ping Ping#ping PUT /ping Ping#ping PATCH /ping Ping#ping DELETE /ping Ping#ping
Whenever providing a top-level route, Psychic will not attempt to infer the controller name for you. This means that you are forced to explicitly provide a controller and action in these cases. Once providing a controller, typescript autocomplete helpers will aid you in selecting an action (i.e. a public method on your controller) to call when that route is hit.