(app *App, w gopher.ResponseWriter, r *gopher.Request)
| 41 | } |
| 42 | |
| 43 | func handleGopher(app *App, w gopher.ResponseWriter, r *gopher.Request) error { |
| 44 | parts := strings.Split(r.Selector, "/") |
| 45 | if app.cfg.App.SingleUser { |
| 46 | if parts[1] != "" { |
| 47 | return handleGopherCollectionPost(app, w, r) |
| 48 | } |
| 49 | return handleGopherCollection(app, w, r) |
| 50 | } |
| 51 | |
| 52 | // Show all public collections (a gopher Reader view, essentially) |
| 53 | if len(parts) == 3 { |
| 54 | return handleGopherCollection(app, w, r) |
| 55 | } |
| 56 | |
| 57 | w.WriteInfo(fmt.Sprintf("Welcome to %s", app.cfg.App.SiteName)) |
| 58 | |
| 59 | colls, err := app.db.GetPublicCollections(app.cfg.App.Host) |
| 60 | if err != nil { |
| 61 | return err |
| 62 | } |
| 63 | |
| 64 | for _, c := range *colls { |
| 65 | w.WriteItem(&gopher.Item{ |
| 66 | Host: stripHostProtocol(app), |
| 67 | Port: app.cfg.Server.GopherPort, |
| 68 | Type: gopher.DIRECTORY, |
| 69 | Description: c.DisplayTitle(), |
| 70 | Selector: "/" + c.Alias + "/", |
| 71 | }) |
| 72 | } |
| 73 | return w.End() |
| 74 | } |
| 75 | |
| 76 | func handleGopherCollection(app *App, w gopher.ResponseWriter, r *gopher.Request) error { |
| 77 | var collAlias, slug string |
nothing calls this directly
no test coverage detected