micro/api/resolver/resolver.go

35 lines
751 B
Go
Raw Normal View History

2019-06-03 18:44:43 +01:00
// Package resolver resolves a http request to an endpoint
package resolver
import (
2020-04-03 09:18:30 +01:00
"errors"
2019-06-03 18:44:43 +01:00
"net/http"
)
2020-04-03 09:18:30 +01:00
var (
// ErrNotFound returned when endpoint is not found
ErrNotFound = errors.New("not found")
// ErrInvalidPath returned on invalid path
2020-04-03 09:18:30 +01:00
ErrInvalidPath = errors.New("invalid path")
)
2019-06-03 18:44:43 +01:00
// Resolver resolves requests to endpoints
type Resolver interface {
Resolve(r *http.Request, opts ...ResolveOption) (*Endpoint, error)
2019-06-03 18:44:43 +01:00
String() string
}
// Endpoint is the endpoint for a http request
type Endpoint struct {
// Endpoint name e.g greeter
2019-06-03 18:44:43 +01:00
Name string
// HTTP Host e.g example.com
Host string
// HTTP Methods e.g GET, POST
Method string
// HTTP Path e.g /greeter.
Path string
// Domain endpoint exists within
Domain string
2020-04-09 11:03:33 +01:00
}