opa: github.com/open-policy-agent/opa/server/writer Index | Files

package writer

import "github.com/open-policy-agent/opa/server/writer"

Package writer contains utilities for writing responses in the server.

Index

Package Files

writer.go

func Bytes Uses

func Bytes(w http.ResponseWriter, code int, bs []byte)

Bytes writes a response with the specified status code and bytes.

func Error Uses

func Error(w http.ResponseWriter, status int, err *types.ErrorV1)

Error writes a response with specified status and error response.

func ErrorAuto Uses

func ErrorAuto(w http.ResponseWriter, err error)

ErrorAuto writes a response with status and code set automatically based on the type of err.

func ErrorString Uses

func ErrorString(w http.ResponseWriter, status int, code string, err error)

ErrorString writes a response with specified status, code, and message set to the the err's string representation.

func HTTPStatus Uses

func HTTPStatus(code int) http.HandlerFunc

HTTPStatus is used to set a specific status code Adapted from https://stackoverflow.com/questions/27711154/what-response-code-to-return-on-a-non-supported-http-method-on-rest

func JSON Uses

func JSON(w http.ResponseWriter, code int, v interface{}, pretty bool)

JSON writes a response with the specified status code and object. The object will be JSON serialized.

Package writer imports 5 packages (graph) and is imported by 12 packages. Updated 2019-08-16. Refresh now. Tools for package owners.