Documentation
¶
Overview ¶
Package httpserver is an almost 1:1 copy (few removals) from inx-app https://github.com/iotaledger/inx-app/blob/428f260abc503227439635b4a9aea5b12b0317c2/pkg/httpserver/http_server.go To get around the additional dependencies
Index ¶
- Constants
- Variables
- func GetAcceptHeaderContentType(c echo.Context, supportedContentTypes ...string) (string, error)
- func GetRequestContentType(c echo.Context, supportedContentTypes ...string) (string, error)
- func GetURL(protocol string, host string, port uint16, path ...string) string
- func JSONResponse(c echo.Context, statusCode int, result interface{}) error
- func NewEcho(logger log.Logger, onHTTPError func(err error, c echo.Context), ...) *echo.Echo
- func ParseBoolQueryParam(c echo.Context, paramName string) (bool, error)
- func ParseUint32QueryParam(c echo.Context, paramName string, maxValue ...uint32) (uint32, error)
- func ParseUnixTimestampQueryParam(c echo.Context, paramName string) (time.Time, error)
- type HTTPErrorResponse
- type HTTPErrorResponseEnvelope
Constants ¶
View Source
const ( MIMEApplicationVendorIOTASerializerV1 = "application/vnd.iota.serializer-v1" ProtocolHTTP = "http" ProtocolHTTPS = "https" ProtocolWS = "ws" ProtocolWSS = "wss" )
Variables ¶
View Source
var ( // ErrInvalidParameter defines the invalid parameter error. ErrInvalidParameter = echo.NewHTTPError(http.StatusBadRequest, "invalid parameter") // ErrNotAcceptable defines the not acceptable error. ErrNotAcceptable = echo.NewHTTPError(http.StatusNotAcceptable) )
Functions ¶
func GetRequestContentType ¶
func JSONResponse ¶
JSONResponse sends the JSON response with status code.
func NewEcho ¶
func NewEcho(logger log.Logger, onHTTPError func(err error, c echo.Context), debugRequestLoggerEnabled bool) *echo.Echo
NewEcho returns a new Echo instance. It hides the banner, adds a default HTTPErrorHandler and the Recover middleware.
func ParseUint32QueryParam ¶
Types ¶
type HTTPErrorResponse ¶
HTTPErrorResponse defines the error struct for the HTTPErrorResponseEnvelope.
type HTTPErrorResponseEnvelope ¶
type HTTPErrorResponseEnvelope struct {
Error HTTPErrorResponse `json:"error"`
}
HTTPErrorResponseEnvelope defines the error response schema for node API responses.
Click to show internal directories.
Click to hide internal directories.