FWHttpServer
Servidor HTTP/REST nativo do AppServer Protheus. Configurado em appserver.ini, expoe funcoes TLPP com @Get/@Post como endpoints automaticamente.
Assinatura: Configurado via appserver.ini secao [HTTPV11]
Retorna: config
FWHttpServer e o servidor HTTP embutido no AppServer Protheus. Habilita expor funcoes TLPP como endpoints REST sem precisar de servidor externo (nginx, IIS).
Habilitar no appserver.ini
[HTTPV11]
ENABLE=1
PORT=8080
INSTANCES=1,2
INSTANCENAME=HTTPREST
MINPROTOCOLVERSION=TLS1.2
; HTTPS opcional:
[HTTPSV11]
ENABLE=1
PORT=8443
INSTANCES=1,2
INSTANCENAME=HTTPSREST
CERTIFICATE=\certs\appserver.pfx
CERTIFICATEPASSWORD=senhaRestart e endpoints automaticos
Apos restart do AppServer, todas as funcoes TLPP com decorator @Get/@Post ja estao expostas:
curl http://localhost:8080/ping
curl -X POST http://localhost:8080/clientes -d '{"nome":"x"}'Limitacoes
- Performance: o AppServer e mono-thread por conexao. Pra alta carga, considere proxy reverso com nginx
- Throttling: nao tem rate limit nativo — implemente manual ou use nginx na frente
- Logs: ficam misturados com console.log do AppServer. Use FwLogger pra separar
Autenticacao
Nao e automatica. Implemente manualmente:
@Post('/api/protected')
function Endpoint()
local cAuth as character
cAuth := httpRequest:getHeader('Authorization')
if !ValidaToken(cAuth)
httpResponse:setStatus(401)
return
endif
// ... logica
return
Exemplos
appserver.ini minimal
[HTTPV11]
ENABLE=1
PORT=8080