Browse Source

static images; updated basic http article

post_vjs2
Levi Olson 6 years ago
parent
commit
34c0830150
4 changed files with 9 additions and 4 deletions
  1. +3
    -0
      app.js
  2. +4
    -2
      posts/basic-http-routing-in-golang.html
  3. +2
    -2
      posts/basic-http-routing-in-golang.md
  4. +0
    -0
      public/images/step2-browser-output.png

+ 3
- 0
app.js View File

@ -5,6 +5,9 @@ const fs = require('fs')
const path = require('path')
const app = express()
app.use(express.static('public'))
app.set('view engine', 'ejs')
app.get('/', (req, res) => {

+ 4
- 2
posts/basic-http-routing-in-golang.html View File

@ -2,7 +2,7 @@
use of external libraries for even the most basic tasks. For example, with JavaScript, most inexperienced developers
seem to use jQuery to do simple tasks like selecting an element and replacing its contents. When you and I both know
jQuery is way overkill for such a task.
<a href="/coming-soon">See my article on Vanilla JS basics.</a>.</p>
<a href="/posts/coming-soon">See my article on Vanilla JS basics.</a>.</p>
<p>I believe that in order to be considered an expert in a language, you must at least be able to demonstrate using the core
language to achieve your goal. In our current case, HTTP routing. Now to be clear, I don't think you need to write everything
from scratch all the time, but you should have a firm grasp on what is available by the core language, and when you are
@ -15,6 +15,8 @@
level basics first. See
<a href="https://tour.golang.org">A Tour of Go</a>.</p>
<h2 id="lets-begin">Let's begin</h2>
<p>The accompanying repo for the code produced in this article is located
<a href="https://github.com/leothelocust/basic-http-routing-in-golang">on github</a>.</p>
<h3 id="step-1">Step 1</h3>
<p>Here is our basic folder structure for this basic http routing example:</p>
<pre><code> basic-http-routing-in-golang/
@ -53,7 +55,7 @@
<code>http.ResponseWriter</code> and a message to display. Our browser will now look like this when we visit the
<code>/url</code> endpoint.</p>
<p>
<img src="file:///c%3A/Users/lolson/Projects/dev/levi/step2-browser-output.png" alt="Browser Output for Step 2 - Hellp HTTP">
<img src="/images/step2-browser-output.png" alt="Browser Output for Step 2 - Hellp HTTP">
</p>
<p>Here is what
<code>main.go</code> looks like at this point:</p>

+ 2
- 2
posts/basic-http-routing-in-golang.md View File

@ -1,4 +1,4 @@
Golang is incredibly powerful. Its standard library has so much to offer, but I think other languages have encouraged the use of external libraries for even the most basic tasks. For example, with JavaScript, most inexperienced developers seem to use jQuery to do simple tasks like selecting an element and replacing its contents. When you and I both know jQuery is way overkill for such a task. [See my article on Vanilla JS basics.](/coming-soon).
Golang is incredibly powerful. Its standard library has so much to offer, but I think other languages have encouraged the use of external libraries for even the most basic tasks. For example, with JavaScript, most inexperienced developers seem to use jQuery to do simple tasks like selecting an element and replacing its contents. When you and I both know jQuery is way overkill for such a task. [See my article on Vanilla JS basics.](/posts/coming-soon).
I believe that in order to be considered an expert in a language, you must at least be able to demonstrate using the core language to achieve your goal. In our current case, HTTP routing. Now to be clear, I don't think you need to write everything from scratch all the time, but you should have a firm grasp on what is available by the core language, and when you are better suited to use an external library. If you are looking for more advanced HTTP routing, then I would suggest using something like [gin](https://github.com/gin-gonic/gin).
@ -48,7 +48,7 @@ Which basically means, `http.HandleFunc("/url", routingFunction)` where `routing
With `fmt.Fprint()` we can pass an `http.ResponseWriter` and a message to display. Our browser will now look like this when we visit the `/url` endpoint.
![Browser Output for Step 2 - Hellp HTTP](step2-browser-output.png)
![Browser Output for Step 2 - Hellp HTTP](images/step2-browser-output.png)
Here is what `main.go` looks like at this point:

posts/step2-browser-output.png → public/images/step2-browser-output.png View File


Loading…
Cancel
Save