added a segment option so that its possible to support event/state based urls such as /posts/1/publish