diff --git a/package/gluon-web/src/template_utils.h b/package/gluon-web/src/template_utils.h
index 5708bfd3724a3eb75be267fb9319198a426bc9d2..35bf706d660ece18e84e3d5beedf97966795bf8b 100644
--- a/package/gluon-web/src/template_utils.h
+++ b/package/gluon-web/src/template_utils.h
@@ -37,7 +37,7 @@ bool buf_append(struct template_buffer *buf, const char *s, size_t len);
 char * buf_destroy(struct template_buffer *buf);
 
 /* read buffer length */
-static inline size_t buf_length(struct template_buffer *buf)
+static inline size_t buf_length(const struct template_buffer *buf)
 {
 	return buf->dptr - buf->data;
 }