otohttp

package module
v0.0.0-...-ff58c20 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 8 Imported by: 0

README

otohttp

Package for rolling Oto services as a JSON/HTTP RPC API.

Documentation

Overview

Package otohttp provides JSON/HTTP RPC API support for Oto defined services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r *http.Request, v interface{}) error

Decode unmarshals the object in the request into v.

func Encode

func Encode(w http.ResponseWriter, r *http.Request, status int, v interface{}) error

Encode writes the response.

Types

type Server

type Server struct {
	// Basepath is the path prefix to match.
	// Default: /oto/
	Basepath string

	// NotFound is the http.Handler to use when a resource is
	// not found.
	NotFound http.Handler
	// OnErr is called when there is an error.
	OnErr func(w http.ResponseWriter, r *http.Request, err error)
	// contains filtered or unexported fields
}

Server handles oto requests.

func NewServer

func NewServer() *Server

NewServer makes a new Server.

func (*Server) Register

func (s *Server) Register(service, method string, h http.HandlerFunc)

Register adds a handler for the specified service method.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the request.

Jump to

Keyboard shortcuts

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