responder: github.com/qor/responder Index | Files

package responder

import "github.com/qor/responder"

Package responder respond differently according to request's accepted mime type

Github: http://github.com/qor/responder

Index

Package Files

responder.go

func Register Uses

func Register(mimeType string, format string)

Register mime type and format

responder.Register("application/json", "json")

type Responder Uses

type Responder struct {
    DefaultResponder func()
    // contains filtered or unexported fields
}

Responder is holder of registed response handlers, response `Request` based on its accepted mime type

func With Uses

func With(formats interface{}, fc func()) *Responder

With could be used to register response handler for mime type formats, the formats could be string or []string

responder.With("html", func() {
  writer.Write([]byte("this is a html request"))
}).With([]string{"json", "xml"}, func() {
  writer.Write([]byte("this is a json or xml request"))
})

func (*Responder) Respond Uses

func (rep *Responder) Respond(request *http.Request)

Respond differently according to request's accepted mime type

func (*Responder) With Uses

func (rep *Responder) With(formats interface{}, fc func()) *Responder

With could be used to register response handler for mime type formats, the formats could be string or []string

Package responder imports 4 packages (graph) and is imported by 30 packages. Updated 2017-11-03. Refresh now. Tools for package owners.