liveBook · Manning

Interface layer

As explained in Learn Go with Pocket-Sized Projects

An API layer is an architectural layer that translates external interface representations into domain operations and translates their results back.

An interface layer translates API-specific requests into domain objects, invokes domain operations, and translates results back into API-specific responses. In a gRPC service, it also converts domain errors into transport status errors. section 10.3.2

Creating a habit through gRPC

CreateHabit applies an API-level default, constructs a domain Habit, calls habit.Create, maps the result into an API response, and returns InvalidArgument or Internal status codes for failures.

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Explains request mapping, response mapping, typed error conversion, and internal failures; defers shared error helpers until multiple endpoints need them.
Examples
Demonstrates CreateHabit, habit frequency defaults, InvalidArgument and Internal responses, and grpcurl invocation.
What it assumes
Assumes an existing domain function, domain validation errors, and generated gRPC API types.
What you can do after
Build a gRPC endpoint that maps domain results and failures into API responses and test it with grpcurl.
How it connects
Connects gRPC endpoints with domain objects, validation, errors, and status codes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.