(app *App, w gopher.ResponseWriter, r *gopher.Request)
| 129 | } |
| 130 | |
| 131 | func handleGopherCollectionPost(app *App, w gopher.ResponseWriter, r *gopher.Request) error { |
| 132 | var collAlias, slug string |
| 133 | var c *Collection |
| 134 | var err error |
| 135 | |
| 136 | parts := strings.Split(r.Selector, "/") |
| 137 | if app.cfg.App.SingleUser { |
| 138 | slug = parts[1] |
| 139 | c, err = app.db.GetCollectionByID(1) |
| 140 | if err != nil { |
| 141 | return err |
| 142 | } |
| 143 | } else { |
| 144 | collAlias = parts[1] |
| 145 | slug = parts[2] |
| 146 | c, err = app.db.GetCollection(collAlias) |
| 147 | if err != nil { |
| 148 | return err |
| 149 | } |
| 150 | } |
| 151 | c.hostName = app.cfg.App.Host |
| 152 | |
| 153 | p, err := app.db.GetPost(slug, c.ID) |
| 154 | if err != nil { |
| 155 | return err |
| 156 | } |
| 157 | |
| 158 | b := bytes.Buffer{} |
| 159 | if p.Title.String != "" { |
| 160 | b.WriteString(p.Title.String + "\n") |
| 161 | } |
| 162 | b.WriteString(p.DisplayDate + "\n\n") |
| 163 | b.WriteString(p.Content) |
| 164 | io.Copy(w, &b) |
| 165 | |
| 166 | return w.End() |
| 167 | } |
no test coverage detected