mattn / mattn/go-stackbuilder

Accept any http.Handler as an argument to New()

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
7
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Having Build() instantiate the Builder with DefaultServeMux is nifty, but the builder itself doesn't use any specific ServeMux functionality. As ServeMux impelements the http.Handler interface, it would be more flexible for Build() to accept http.Handler and not only http.ServeMux.

This would help greatly in situations where one does not want to use http.ServeMux at all. Instead of having to plug their own handler to DefaultServeMux (or a new ServeMux), the user could simply do:

stackbuilder.New(H).Build(M1, M2)

Where H is the application handler and M1 and M2 are middleware.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating New() and Build() in the Go package and read how the builder currently receives and uses its handler. Update the behavior so the example stackbuilder.New(H).Build(M1, M2) works with any http.Handler, then verify the existing package tests and middleware flow still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.