adsa-cms: github.com/mmanjoura/adsa-cms/responder Index | Files

package responder

import "github.com/mmanjoura/adsa-cms/responder"

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

Github: http://github.com/mmanjoura/adsa-cms/responder

Index

Package Files

responder.go

func Register Uses

func Register(mime string, format string)

Register new mime type and format

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

type Responder Uses

type Responder struct {
    // 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 3 packages (graph) and is imported by 4 packages. Updated 2017-06-08. Refresh now. Tools for package owners.