mocker

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2020 License: MIT Imports: 3 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Build Status Coverage Status Go Report Card License Repo Size

quickly test your HTTP requests

Usage

package main

import (
	"fmt"
	"github.com/axetroy/mocker"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main()  {
	gin.SetMode(gin.ReleaseMode)
	
	router := gin.Default()
	
    router.GET("/", func(context *gin.Context) {
        context.String(http.StatusOK, "hello world!")
    })
	
	mock := mocker.New(router)
	
	res := mock.Get("/", nil, nil)
	
	fmt.Println(res.Body.String()) // hello world!
}

License

The MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header map[string]string

type Mocker

type Mocker struct {
	Router http.Handler
}

func New

func New(router http.Handler) *Mocker

func (*Mocker) Delete

func (c *Mocker) Delete(path string, body []byte, header *Header) *httptest.ResponseRecorder

func (*Mocker) Get

func (c *Mocker) Get(path string, body []byte, header *Header) *httptest.ResponseRecorder

func (*Mocker) Head

func (c *Mocker) Head(path string, body []byte, header *Header) *httptest.ResponseRecorder

func (*Mocker) Options

func (c *Mocker) Options(path string, body []byte, header *Header) *httptest.ResponseRecorder

func (*Mocker) Patch

func (c *Mocker) Patch(path string, body []byte, header *Header) *httptest.ResponseRecorder

func (*Mocker) Post

func (c *Mocker) Post(path string, body []byte, header *Header) *httptest.ResponseRecorder

func (*Mocker) Put

func (c *Mocker) Put(path string, body []byte, header *Header) *httptest.ResponseRecorder

func (*Mocker) Request

func (c *Mocker) Request(method string, path string, body []byte, header *Header) *httptest.ResponseRecorder

func (*Mocker) Trace

func (c *Mocker) Trace(path string, body []byte, header *Header) *httptest.ResponseRecorder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL