package server import ( "net/http" "strings" ) func (s *Server) handlePlainView( w http.ResponseWriter, r *http.Request, ) { path := strings.TrimPrefix( r.URL.Path, "/v/plain", ) if path == "" { path = "/" } if !strings.HasPrefix(path, "/") { path = "/" + path } objectUUID, err := s.store.ResolvePath( path, ) if err != nil { http.NotFound(w, r) return } latest, err := s.store.GetLatestRevision( objectUUID, ) if err != nil { http.Error(w, err.Error(), 500) return } w.Header().Set( "Content-Type", "text/plain; charset=utf-8", ) _, _ = w.Write( []byte(latest.Body), ) }