From 86b4573c22af46582d5018f9b86cb9f96f5f6c44 Mon Sep 17 00:00:00 2001 From: Robert Bielik Date: Sat, 28 Dec 2019 08:35:17 +0100 Subject: Add http server method for getting address --- src/supplemental/http/http_public.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/supplemental/http/http_public.c b/src/supplemental/http/http_public.c index 3152c41f..d2e876ab 100644 --- a/src/supplemental/http/http_public.c +++ b/src/supplemental/http/http_public.c @@ -9,8 +9,8 @@ // #include "core/nng_impl.h" -#include "nng/supplemental/http/http.h" #include "http_api.h" +#include "nng/supplemental/http/http.h" #include "nng/supplemental/tls/tls.h" // Symbols in this file are "public" versions of the HTTP API. @@ -779,6 +779,22 @@ nng_http_server_get_tls(nng_http_server *srv, struct nng_tls_config **cfgp) #endif } +int +nng_http_server_get_addr(nng_http_server *srv, nng_sockaddr *addrp) +{ +#ifdef NNG_SUPP_HTTP + size_t size = sizeof(nng_sockaddr); + if (srv == NULL || addrp == NULL) + return NNG_EINVAL; + return (nni_http_server_getx( + srv, NNG_OPT_LOCADDR, addrp, &size, NNI_TYPE_SOCKADDR)); +#else + NNI_ARG_UNUSED(srv); + NNI_ARG_UNUSED(addrp); + return (NNG_ENOTSUP); +#endif +} + int nng_http_server_res_error(nng_http_server *srv, nng_http_res *res) { -- cgit v1.2.3-70-g09d2