Skip to content

pokerblow/go-httptestutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Http testing

Example

// Init router 
var e *gin.Engine = // get form your gin router 
var testRouter = httptestutil.NewRouter(e)
...
    headers := map[string]string{"Authorization": "Bearer eyJh...."}
    rr := testRouter.POST(t, "/blah", `{"name":"my name"}`, headers)
    if rr.Code != http.StatusOK {
        t.Errorf("failed response code, buddy ...")
    }

Options

var defaultHeaders = map[string]string{"Authorization": "Bearer eyJh...."}
var testRouter = httptestutil.NewRouter(e).BasePath("/api/your-service").Headers(defaultHeaders)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages