Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func (s *server) loadTemplates() {
}
}

func (s *server) ServeFastSearch(ctx context.Context, w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/search/?q=" + r.URL.Query().Get(":query"), 303)
}

func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.inner.ServeHTTP(w, r)
}
Expand Down Expand Up @@ -555,6 +559,7 @@ func New(cfg *config.Config) (http.Handler, error) {

m.Add("GET", "/api/v1/search/:backend", srv.Handler(srv.ServeAPISearch))
m.Add("GET", "/api/v1/search/", srv.Handler(srv.ServeAPISearch))
m.Add("GET", "/:query/", srv.Handler(srv.ServeFastSearch))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whitespace here looks odd — configure your editor to run gofmt each time you hit Save.


var h http.Handler = m

Expand Down