add basic http server

This commit is contained in:
Joel Wetzell
2025-11-22 14:25:15 -06:00
parent b84edb641b
commit 1ae6dc3719
2 changed files with 147 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package processing
import (
"context"
"fmt"
"io"
"net/http"
)
type HTTPRequestEncode struct {
config ProcessorConfig
}
func (hre *HTTPRequestEncode) Process(ctx context.Context, payload any) (any, error) {
payloadRequest, ok := payload.(*http.Request)
if !ok {
return nil, fmt.Errorf("http.request.encode processor only accepts an OSCMessage")
}
bytes, err := io.ReadAll(payloadRequest.Body)
if err != nil {
return nil, err
}
return bytes, nil
}
func (hre *HTTPRequestEncode) Type() string {
return hre.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "http.request.encode",
New: func(config ProcessorConfig) (Processor, error) {
return &HTTPRequestEncode{config: config}, nil
},
})
}