> ## Documentation Index
> Fetch the complete documentation index at: https://docs.restate.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Serving

> Create an endpoint to serve your services.

The Restate SDK is served as a HTTP handler. You can choose to run this in a
standalone HTTP2 server, or connect the handler into a FaaS system like Lambda.

## Creating a HTTP2 server

1. Create the Restate Server
2. Bind one or multiple services to it.
3. Listen on the specified port for connections and requests.

```go {"CODE_LOAD::go/develop/serving.go#endpoint"}  theme={null}
if err := server.NewRestate().
  Bind(restate.Reflect(MyService{})).
  Bind(restate.Reflect(MyObject{})).
  Bind(restate.Reflect(MyWorkflow{})).
  Start(context.Background(), ":9080"); err != nil {
  log.Fatal(err)
}
```

<Accordion title="Customizing the HTTP2 server">
  If you need to customize the HTTP2 server, or serve over HTTP1.1
  you can call `.Handler()` instead of `Start()`, and then use the
  handler as normal. To discover services over HTTP1.1 you must
  provide the `--use-http1.1` CLI flag.

  ```go {"CODE_LOAD::go/develop/serving.go#custom_endpoint"}  theme={null}
  handler, err := server.NewRestate().
  Bind(restate.Reflect(MyService{})).
  Bind(restate.Reflect(MyObject{})).
  Bind(restate.Reflect(MyWorkflow{})).
  Handler()
  if err != nil {
  log.Fatal(err)
  }
  ```

  By default, this handler will advertise itself as working
  bidirectionally; the SDK will try to get completions from the runtime
  during execution.

  However, you can use the method `.Bidirectional(false)` on the endpoint
  builder to change this on platforms that do not support bidirectional
  communication, such as Lambda. If you don't do this your handler may get
  stuck.
</Accordion>

## Creating a Lambda handler

To register your service as a Lambda function change the endpoint into a Lambda handler
with `.LambdaHandler()`, and pass this handler to [`lambda.Start`](https://pkg.go.dev/github.com/aws/aws-lambda-go/lambda#Start).

```go {"CODE_LOAD::go/develop/servinglambda.go#lambda"}  theme={null}
handler, err := server.NewRestate().
  Bind(restate.Reflect(MyService{})).
  Bind(restate.Reflect(MyObject{})).
  Bind(restate.Reflect(MyWorkflow{})).
  Bidirectional(false).
  LambdaHandler()
if err != nil {
  log.Fatal(err)
}
lambda.Start(handler)
```

Have a look at the [deployment section](/services/deploy/lambda) for guidance on how to deploy your services on AWS Lambda.

The implementation of your services and handlers remains the same for both deployment options.

## Validating request identity

SDKs can validate that incoming requests come from a particular Restate
instance. You can find out more about request identity in the [Security docs](/services/security#locking-down-service-access)

```go {"CODE_LOAD::go/develop/serving.go#identity"}  theme={null}
if err := server.NewRestate().
  Bind(restate.Reflect(MyService{})).
  WithIdentityV1("publickeyv1_w7YHemBctH5Ck2nQRQ47iBBqhNHy4FV7t2Usbye2A6f").
  Start(context.Background(), ":9080"); err != nil {
  log.Fatal(err)
}
```
