DEV Community

Ega Prasetya
Ega Prasetya

Posted on

1 2

Golang Web - REST API With Mux

So today i gonna show you how to create RestApi With mux in Go. So let`s do it..

PRACTICE

First step u should to import package like a picture, u should to download package mux with go get -u github.com/gorilla/mux

Alt Text

So next create function main and then create code for the CRUD

Alt Text

if u done, create 5 function for handler CRUD

Alt Text

Alt Text

So next create struct Book and Author Struct for CRUD data

Alt Text

TESTING

i use POSTMAN for the testing this API

Alt Text

So here we go, Finally! Hope your enjoy it.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️