partial

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2018 License: MIT Imports: 2 Imported by: 0

README

gear-partial-response

Build Status Coverage Status

Partial response middleware for Gear.

Installation

go get -u github.com/teambition/gear-partial-response

Documentation

API documentation can be found here: https://godoc.org/github.com/teambition/gear-partial-response

Usage

import (
	"github.com/teambition/gear"
	partial "github.com/teambition/gear-partial-response"
)
When initializing the gear application:
app := gear.New()
app.Set(gear.SetSender, partial.New(partial.Options{Query: "fields"}))
In controller function:
app.Use(func(ctx *gear.Context) error {
	// ...
	return ctx.Send(http.StatusOK, data)
})

Documentation

Overview

Example
package main

import (
	"github.com/teambition/gear"
	partial "github.com/teambition/gear-partial-response"
)

func main() {
	app := gear.New()
	app.Set(gear.SetSender, partial.New(partial.Options{Query: "fields"}))
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Query specifies the querystring to use. By defaults it is "fields".
	Query string
}

Options is the partial response middleware options.

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

Sender is to implement gear.Sender interface.

func New

func New(opts Options) *Sender

New returns a new partial response middleware for your gear app.

func (*Sender) Send

func (s *Sender) Send(ctx *gear.Context, code int, data interface{}) (err error)

Send is to implement gear.Sender interface.

Jump to

Keyboard shortcuts

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